Electroneum
gen_ring_signature_1 Class Reference

#include <ring_signature_1.h>

Inheritance diagram for gen_ring_signature_1:
Collaboration diagram for gen_ring_signature_1:

Public Member Functions

 gen_ring_signature_1 ()
 
bool generate (std::vector< test_event_entry > &events) const
 
bool check_balances_1 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
 
bool check_balances_2 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
 
- Public Member Functions inherited from test_chain_unit_base
void register_callback (const std::string &cb_name, verify_callback cb)
 
bool verify (const std::string &cb_name, cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
 
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
 
bool check_tx_verification_context (const cryptonote::tx_verification_context &tvc, bool, size_t, const cryptonote::transaction &)
 
bool check_tx_verification_context_array (const std::vector< cryptonote::tx_verification_context > &tvcs, size_t, size_t, const std::vector< cryptonote::transaction > &)
 

Additional Inherited Members

- Public Types inherited from test_chain_unit_base
typedef boost::function< bool(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)> verify_callback
 
typedef std::map< std::string, verify_callbackcallbacks_map
 

Detailed Description

Definition at line 38 of file ring_signature_1.h.

Constructor & Destructor Documentation

◆ gen_ring_signature_1()

gen_ring_signature_1::gen_ring_signature_1 ( )

Definition at line 42 of file ring_signature_1.cpp.

43 {
46 }
#define REGISTER_CALLBACK(CB_NAME, CLBACK)
Definition: chaingen.h:827
bool check_balances_2(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_balances_1(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
Here is the call graph for this function:

Member Function Documentation

◆ check_balances_1()

bool gen_ring_signature_1::check_balances_1 ( cryptonote::core c,
size_t  ev_index,
const std::vector< test_event_entry > &  events 
)

Definition at line 98 of file ring_signature_1.cpp.

99 {
100  DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_1::check_balances_1");
101 
102  m_bob_account = boost::get<account_base>(events[3]);
103  m_alice_account = boost::get<account_base>(events[4]);
104 
105  std::vector<block> blocks;
106  bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, blocks);
108 
109  std::vector<cryptonote::block> chain;
110  map_hash2tx_t mtx;
111  r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back()));
113  CHECK_EQ(MK_COINS(130) + 2 * rnd_11 + rnd_20 + 3 * rnd_29, get_balance(m_bob_account, chain, mtx));
114  CHECK_EQ(0, get_balance(m_alice_account, chain, mtx));
115 
116  return true;
117 }
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
Definition: chaingen.cpp:1072
uint64_t get_balance(const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
Definition: chaingen.cpp:940
#define CHECK_TEST_CONDITION(cond)
Definition: chaingen.h:1057
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition: chaingen.h:163
crypto::hash get_block_hash(uint64_t height)
#define MK_COINS(amount)
Definition: chaingen.h:1060
#define CHECK_EQ(v1, v2)
Definition: chaingen.h:1058
#define DEFINE_TESTS_ERROR_CONTEXT(text)
Definition: chaingen.h:1056
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_balances_2()

bool gen_ring_signature_1::check_balances_2 ( cryptonote::core c,
size_t  ev_index,
const std::vector< test_event_entry > &  events 
)

Definition at line 119 of file ring_signature_1.cpp.

120 {
121  DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_1::check_balances_2");
122 
123  std::vector<block> blocks;
124  bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, blocks);
126 
127  std::vector<cryptonote::block> chain;
128  map_hash2tx_t mtx;
129  r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back()));
131  CHECK_EQ(MK_COINS(1), get_balance(m_bob_account, chain, mtx));
132  CHECK_EQ(MK_COINS(129) + 2 * rnd_11 + rnd_20 + 3 * rnd_29 - TESTS_DEFAULT_FEE, get_balance(m_alice_account, chain, mtx));
133 
134  return true;
135 }
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
Definition: chaingen.cpp:1072
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061
uint64_t get_balance(const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
Definition: chaingen.cpp:940
#define CHECK_TEST_CONDITION(cond)
Definition: chaingen.h:1057
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition: chaingen.h:163
crypto::hash get_block_hash(uint64_t height)
#define MK_COINS(amount)
Definition: chaingen.h:1060
#define CHECK_EQ(v1, v2)
Definition: chaingen.h:1058
#define DEFINE_TESTS_ERROR_CONTEXT(text)
Definition: chaingen.h:1056
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate()

bool gen_ring_signature_1::generate ( std::vector< test_event_entry > &  events) const

Definition at line 56 of file ring_signature_1.cpp.

57 {
58  uint64_t ts_start = 1338224400;
59 
60  GENERATE_ACCOUNT(miner_account);
61 
62  // events
63  MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start); // 0
64  MAKE_ACCOUNT(events, some_account_1); // 1
65  MAKE_ACCOUNT(events, some_account_2); // 2
66  MAKE_ACCOUNT(events, bob_account); // 3
67  MAKE_ACCOUNT(events, alice_account); // 4
68  MAKE_NEXT_BLOCK(events, blk_1, blk_0, miner_account); // 5
69  MAKE_NEXT_BLOCK(events, blk_2, blk_1, miner_account); // 6
70  MAKE_NEXT_BLOCK(events, blk_3, blk_2, miner_account); // 7
71  MAKE_NEXT_BLOCK(events, blk_4, blk_3, miner_account); // 8
72  REWIND_BLOCKS(events, blk_5, blk_4, miner_account); // <N blocks>
73  REWIND_BLOCKS(events, blk_5r, blk_5, miner_account); // <N blocks>
74  MAKE_TX_LIST_START(events, txs_blk_6, miner_account, bob_account, MK_COINS(1), blk_5); // 9 + 2N
75  MAKE_TX_LIST(events, txs_blk_6, miner_account, bob_account, MK_COINS(11) + rnd_11, blk_5); // 10 + 2N
76  MAKE_TX_LIST(events, txs_blk_6, miner_account, bob_account, MK_COINS(11) + rnd_11, blk_5); // 11 + 2N
77  MAKE_TX_LIST(events, txs_blk_6, miner_account, bob_account, MK_COINS(20) + rnd_20, blk_5); // 12 + 2N
78  MAKE_TX_LIST(events, txs_blk_6, miner_account, bob_account, MK_COINS(29) + rnd_29, blk_5); // 13 + 2N
79  MAKE_TX_LIST(events, txs_blk_6, miner_account, bob_account, MK_COINS(29) + rnd_29, blk_5); // 14 + 2N
80  MAKE_TX_LIST(events, txs_blk_6, miner_account, bob_account, MK_COINS(29) + rnd_29, blk_5); // 15 + 2N
81  MAKE_TX_LIST(events, txs_blk_6, miner_account, some_account_1, MK_COINS(11) + rnd_11, blk_5); // 16 + 2N
82  MAKE_TX_LIST(events, txs_blk_6, miner_account, some_account_1, MK_COINS(11) + rnd_11, blk_5); // 17 + 2N
83  MAKE_TX_LIST(events, txs_blk_6, miner_account, some_account_1, MK_COINS(11) + rnd_11, blk_5); // 18 + 2N
84  MAKE_TX_LIST(events, txs_blk_6, miner_account, some_account_1, MK_COINS(11) + rnd_11, blk_5); // 19 + 2N
85  MAKE_TX_LIST(events, txs_blk_6, miner_account, some_account_1, MK_COINS(20) + rnd_20, blk_5); // 20 + 2N
86  MAKE_TX_LIST(events, txs_blk_6, miner_account, some_account_2, MK_COINS(20) + rnd_20, blk_5); // 21 + 2N
87  MAKE_NEXT_BLOCK_TX_LIST(events, blk_6, blk_5r, miner_account, txs_blk_6); // 22 + 2N
88  DO_CALLBACK(events, "check_balances_1"); // 23 + 2N
89  REWIND_BLOCKS(events, blk_6r, blk_6, miner_account); // <N blocks>
90  // 129 = 11 + 11 + 20 + 29 + 29 + 29
91  MAKE_TX_MIX(events, tx_0, bob_account, alice_account, MK_COINS(129) + 2 * rnd_11 + rnd_20 + 3 * rnd_29 - TESTS_DEFAULT_FEE, 2, blk_6); // 24 + 3N
92  MAKE_NEXT_BLOCK_TX1(events, blk_7, blk_6r, miner_account, tx_0); // 25 + 3N
93  DO_CALLBACK(events, "check_balances_2"); // 26 + 3N
94 
95  return true;
96 }
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
Definition: chaingen.h:849
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition: chaingen.h:839
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition: chaingen.h:933
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
Definition: chaingen.h:893
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
Definition: chaingen.h:833
unsigned __int64 uint64_t
Definition: stdint.h:136
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition: chaingen.h:935
#define MAKE_ACCOUNT(VEC_EVENTS, account)
Definition: chaingen.h:815
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition: chaingen.h:890
#define MK_COINS(amount)
Definition: chaingen.h:1060
#define GENERATE_ACCOUNT(account)
Definition: chaingen.h:801
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
Definition: chaingen.h:820
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
Definition: chaingen.h:867

The documentation for this class was generated from the following files: