Electroneum
gen_simple_chain_001 Class Reference

#include <chaingen_tests_list.h>

Inheritance diagram for gen_simple_chain_001:
Collaboration diagram for gen_simple_chain_001:

Public Member Functions

 gen_simple_chain_001 ()
 
bool generate (std::vector< test_event_entry > &events)
 
bool verify_callback_1 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
 
bool verify_callback_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 50 of file chaingen_tests_list.h.

Constructor & Destructor Documentation

◆ gen_simple_chain_001()

gen_simple_chain_001::gen_simple_chain_001 ( )

Definition at line 99 of file chaingen001.cpp.

100 {
103 }
#define REGISTER_CALLBACK(CB_NAME, CLBACK)
Definition: chaingen.h:827
bool verify_callback_1(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool verify_callback_2(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

◆ generate()

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

Definition at line 105 of file chaingen001.cpp.

106 {
107  uint64_t ts_start = 1338224400;
108 
110  GENERATE_ACCOUNT(alice);
111 
112  MAKE_GENESIS_BLOCK(events, blk_0, miner, ts_start);
113  MAKE_NEXT_BLOCK(events, blk_1, blk_0, miner);
114  MAKE_NEXT_BLOCK(events, blk_1_side, blk_0, miner);
115  MAKE_NEXT_BLOCK(events, blk_2, blk_1, miner);
116  //MAKE_TX(events, tx_0, first_miner_account, alice, 151, blk_2);
117 
118  std::vector<cryptonote::block> chain;
119  map_hash2tx_t mtx;
120  /*bool r = */find_block_chain(events, chain, mtx, get_block_hash(boost::get<cryptonote::block>(events[3])));
121  std::cout << "BALANCE = " << get_balance(miner, chain, mtx) << std::endl;
122 
123  REWIND_BLOCKS(events, blk_2r, blk_2, miner);
124  MAKE_TX_LIST_START(events, txlist_0, miner, alice, MK_COINS(1), blk_2);
125  MAKE_TX_LIST(events, txlist_0, miner, alice, MK_COINS(2), blk_2);
126  MAKE_TX_LIST(events, txlist_0, miner, alice, MK_COINS(4), blk_2);
127  MAKE_NEXT_BLOCK_TX_LIST(events, blk_3, blk_2r, miner, txlist_0);
128  REWIND_BLOCKS(events, blk_3r, blk_3, miner);
129  MAKE_TX(events, tx_1, miner, alice, MK_COINS(50), blk_3);
130  MAKE_NEXT_BLOCK_TX1(events, blk_4, blk_3r, miner, tx_1);
131  REWIND_BLOCKS(events, blk_4r, blk_4, miner);
132  MAKE_TX(events, tx_2, miner, alice, MK_COINS(50), blk_4);
133  MAKE_NEXT_BLOCK_TX1(events, blk_5, blk_4r, miner, tx_2);
134  REWIND_BLOCKS(events, blk_5r, blk_5, miner);
135  MAKE_TX(events, tx_3, miner, alice, MK_COINS(50), blk_5);
136  MAKE_NEXT_BLOCK_TX1(events, blk_6, blk_5r, miner, tx_3);
137 
138  DO_CALLBACK(events, "verify_callback_1");
139  //e.t.c.
140  //MAKE_BLOCK_TX1(events, blk_3, 3, get_block_hash(blk_0), get_test_target(), first_miner_account, ts_start + 10, tx_0);
141  //MAKE_BLOCK_TX1(events, blk_3, 3, get_block_hash(blk_0), get_test_target(), first_miner_account, ts_start + 10, tx_0);
142  //DO_CALLBACK(events, "verify_callback_2");
143 
144 /* std::vector<const cryptonote::block*> chain;
145  map_hash2tx_t mtx;
146  if (!find_block_chain(events, chain, mtx, get_block_hash(blk_6)))
147  throw;
148  cout << "miner = " << get_balance(first_miner_account, events, chain, mtx) << endl;
149  cout << "alice = " << get_balance(alice, events, chain, mtx) << endl;*/
150 
151  return true;
152 }
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
Definition: chaingen.h:849
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 MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition: chaingen.h:839
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 MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition: chaingen.h:933
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition: chaingen.h:163
#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 REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition: chaingen.h:890
#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD)
Definition: chaingen.h:903
crypto::hash get_block_hash(uint64_t height)
#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
Here is the call graph for this function:

◆ verify_callback_1()

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

Definition at line 154 of file chaingen001.cpp.

155 {
156  return true;
157 }
Here is the caller graph for this function:

◆ verify_callback_2()

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

Definition at line 159 of file chaingen001.cpp.

160 {
161  return true;
162 }
Here is the caller graph for this function:

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