Electroneum
Loading...
Searching...
No Matches
gen_simple_chain_split_1 Class Reference

#include <chain_split_1.h>

Inheritance diagram for gen_simple_chain_split_1:
Collaboration diagram for gen_simple_chain_split_1:

Public Member Functions

 gen_simple_chain_split_1 ()
bool generate (std::vector< test_event_entry > &events) const
bool check_split_not_switched (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_not_switched2 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_switched (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_not_switched_back (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_switched_back_1 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_switched_back_2 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_mempool_1 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_mempool_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 chain_split_1.h.

Constructor & Destructor Documentation

◆ gen_simple_chain_split_1()

gen_simple_chain_split_1::gen_simple_chain_split_1 ( )

Definition at line 41 of file chain_split_1.cpp.

42{
51 //REGISTER_CALLBACK("check_orphaned_chain_1", gen_simple_chain_split_1::check_orphaned_chain_1);
52 //REGISTER_CALLBACK("check_orphaned_switched_to_alternative", gen_simple_chain_split_1::check_orphaned_switched_to_alternative);
53 //REGISTER_CALLBACK("check_orphaned_chain_2", gen_simple_chain_split_1::check_orphaned_chain_2);
54 //REGISTER_CALLBACK("check_orphaned_switched_to_main", gen_simple_chain_split_1::check_orphaned_switched_to_main);
55 //REGISTER_CALLBACK("check_orphaned_chain_38", gen_simple_chain_split_1::check_orphaned_chain_38);
56 //REGISTER_CALLBACK("check_orphaned_chain_39", gen_simple_chain_split_1::check_orphaned_chain_39);
57 //REGISTER_CALLBACK("check_orphaned_chain_40", gen_simple_chain_split_1::check_orphaned_chain_40);
58 //REGISTER_CALLBACK("check_orphaned_chain_41", gen_simple_chain_split_1::check_orphaned_chain_41);
59}
#define REGISTER_CALLBACK(CB_NAME, CLBACK)
Definition chaingen.h:827
bool check_split_switched(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_mempool_2(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_switched_back_2(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_switched_back_1(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_not_switched(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_not_switched2(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_split_not_switched_back(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_mempool_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_mempool_1()

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

Definition at line 171 of file chain_split_1.cpp.

172{
173 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_mempool_1");
175 return true;
176}
#define DEFINE_TESTS_ERROR_CONTEXT(text)
Definition chaingen.h:1056
#define CHECK_TEST_CONDITION(cond)
Definition chaingen.h:1057
size_t get_pool_transactions_count() const
get the total number of transactions in the pool
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_mempool_2()

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

Definition at line 164 of file chain_split_1.cpp.

165{
166 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_mempool_2");
168 return true;
169}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_split_not_switched()

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

Definition at line 178 of file chain_split_1.cpp.

179{
180 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_split_not_switched");
181 //check height
184 CHECK_TEST_CONDITION(c.get_tail_id() == get_block_hash(boost::get<cryptonote::block>(events[8])));
186 return true;
187}
size_t get_alternative_blocks_count() const
returns the number of alternative blocks stored
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
size_t get_blockchain_total_transactions() const
gets the total number of transactions on the main chain
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
crypto::hash get_block_hash(uint64_t height)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_split_not_switched2()

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

Definition at line 189 of file chain_split_1.cpp.

190{
191 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_split_not_switched2");
192 //check height
195 CHECK_TEST_CONDITION(c.get_tail_id() == get_block_hash(boost::get<cryptonote::block>(events[8])));
197 return true;
198}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_split_not_switched_back()

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

Definition at line 212 of file chain_split_1.cpp.

213{
214 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_split_not_switched_back");
215 //check height
218 CHECK_TEST_CONDITION(c.get_tail_id() == get_block_hash(boost::get<cryptonote::block>(events[19])));
220
221 return true;
222}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_split_switched()

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

Definition at line 200 of file chain_split_1.cpp.

201{
202 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_split_switched");
203
204 //check height
207 CHECK_TEST_CONDITION(c.get_tail_id() == get_block_hash(boost::get<cryptonote::block>(events[14])));
209 return true;
210}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_split_switched_back_1()

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

Definition at line 224 of file chain_split_1.cpp.

225{
226 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_split_switched_back_1");
227
228 //check height
231 CHECK_TEST_CONDITION(c.get_tail_id() == get_block_hash(boost::get<cryptonote::block>(events[26])));
233
234 return true;
235}//-----------------------------------------------------------------------------------------------------
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_split_switched_back_2()

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

Definition at line 236 of file chain_split_1.cpp.

237{
238 DEFINE_TESTS_ERROR_CONTEXT("gen_simple_chain_split_1::check_split_switched_back_2");
239
240 //check height
243 CHECK_TEST_CONDITION(c.get_tail_id() == get_block_hash(boost::get<cryptonote::block>(events[28])));
245 return true;
246}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate()

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

Definition at line 61 of file chain_split_1.cpp.

62{
63 uint64_t ts_start = 1338224400;
64 /*
65 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <-- main blockchain height
66 (0 )-(1 )-(2 )-(3 )-(4 )-(5 ) -(6 ) -(7 ) -(8 )|-(17) -(18) -(19) -(20) -(21)|-(22)|-(23)|-(24)|
67 \ -(9 ) -(10)|-(11)|-(12)|-(13) -(14) -(15) -(16)
68 -(25) -(26)|
69 -(27)| #check switching to alternative
70 ----------------------------------------------------------------------------------
71 -(28) -(29) -(30) -(31)|
72 -(32)| #check switching orphans to main
73 ----------------------------------------------------------------------------------
74 -(33) -(34) -(35) -(36) -(37) -(38)|
75 -(39)| #<--this part becomes alternative chain connected to main
76 -(40)| #still marked as orphaned
77 -(41)|
78 #check orphaned with block in the middle of the orphaned chain
79 */
80
81 GENERATE_ACCOUNT(first_miner_account);
82 // events index
83 MAKE_GENESIS_BLOCK(events, blk_0, first_miner_account, ts_start); // 0
84 MAKE_NEXT_BLOCK(events, blk_1, blk_0, first_miner_account); // 1
85 MAKE_NEXT_BLOCK(events, blk_2, blk_1, first_miner_account); // 2
86 MAKE_NEXT_BLOCK(events, blk_3, blk_2, first_miner_account); // 3
87 MAKE_NEXT_BLOCK(events, blk_4, blk_3, first_miner_account); // 4
88 MAKE_NEXT_BLOCK(events, blk_5, blk_4, first_miner_account); // 5
89 MAKE_NEXT_BLOCK(events, blk_6, blk_5, first_miner_account); // 6
90 MAKE_NEXT_BLOCK(events, blk_7, blk_6, first_miner_account); // 7
91 MAKE_NEXT_BLOCK(events, blk_8, blk_7, first_miner_account); // 8
92 //split
93 MAKE_NEXT_BLOCK(events, blk_9, blk_5, first_miner_account); // 9
94 MAKE_NEXT_BLOCK(events, blk_10, blk_9, first_miner_account); // 10
95 DO_CALLBACK(events, "check_split_not_switched"); // 11
96 MAKE_NEXT_BLOCK(events, blk_11, blk_10, first_miner_account); // 12
97 DO_CALLBACK(events, "check_split_not_switched2"); // 13
98 MAKE_NEXT_BLOCK(events, blk_12, blk_11, first_miner_account); // 14
99 DO_CALLBACK(events, "check_split_switched"); // 15
100 MAKE_NEXT_BLOCK(events, blk_13, blk_12, first_miner_account); // 16
101 MAKE_NEXT_BLOCK(events, blk_14, blk_13, first_miner_account); // 17
102 MAKE_NEXT_BLOCK(events, blk_15, blk_14, first_miner_account); // 18
103 MAKE_NEXT_BLOCK(events, blk_16, blk_15, first_miner_account); // 19
104 //split again and check back switching
105 MAKE_NEXT_BLOCK(events, blk_17, blk_8, first_miner_account); // 20
106 MAKE_NEXT_BLOCK(events, blk_18, blk_17, first_miner_account); // 21
107 MAKE_NEXT_BLOCK(events, blk_19, blk_18, first_miner_account); // 22
108 MAKE_NEXT_BLOCK(events, blk_20, blk_19, first_miner_account); // 23
109 MAKE_NEXT_BLOCK(events, blk_21, blk_20, first_miner_account); // 24
110 DO_CALLBACK(events, "check_split_not_switched_back"); // 25
111 MAKE_NEXT_BLOCK(events, blk_22, blk_21, first_miner_account); // 26
112 DO_CALLBACK(events, "check_split_switched_back_1"); // 27
113 MAKE_NEXT_BLOCK(events, blk_23, blk_22, first_miner_account); // 28
114 DO_CALLBACK(events, "check_split_switched_back_2"); // 29
115
116 REWIND_BLOCKS(events, blk_23r, blk_23, first_miner_account); // 30...N1
117 GENERATE_ACCOUNT(alice);
118 MAKE_TX(events, tx_0, first_miner_account, alice, MK_COINS(10), blk_23); // N1+1
119 MAKE_TX(events, tx_1, first_miner_account, alice, MK_COINS(20), blk_23); // N1+2
120 MAKE_TX(events, tx_2, first_miner_account, alice, MK_COINS(30), blk_23); // N1+3
121 DO_CALLBACK(events, "check_mempool_1"); // N1+4
122 MAKE_NEXT_BLOCK_TX1(events, blk_24, blk_23r, first_miner_account, tx_0); // N1+5
123 DO_CALLBACK(events, "check_mempool_2"); // N1+6
124 /*
125 //check orphaned blocks
126 MAKE_NEXT_BLOCK_NO_ADD(events, blk_orph_27, blk_16, get_test_target(), first_miner_account);
127 MAKE_NEXT_BLOCK(events, blk_25, blk_orph_27, get_test_target(), first_miner_account); // 36
128 MAKE_NEXT_BLOCK(events, blk_26, blk_25, get_test_target(), first_miner_account); // 37
129 DO_CALLBACK(events, "check_orphaned_chain_1"); // 38
130 ADD_BLOCK(events, blk_orph_27); // 39
131 DO_CALLBACK(events, "check_orphaned_switched_to_alternative"); // 40
132
133 //check orphaned check to main chain
134 MAKE_NEXT_BLOCK_NO_ADD(events, blk_orph_32, blk_16, get_test_target(), first_miner_account);
135 MAKE_NEXT_BLOCK(events, blk_28, blk_orph_32, get_test_target(), first_miner_account); // 41
136 MAKE_NEXT_BLOCK(events, blk_29, blk_28, get_test_target(), first_miner_account); // 42
137 MAKE_NEXT_BLOCK(events, blk_30, blk_29, get_test_target(), first_miner_account); // 43
138 MAKE_NEXT_BLOCK(events, blk_31, blk_30, get_test_target(), first_miner_account); // 44
139 DO_CALLBACK(events, "check_orphaned_chain_2"); // 45
140 ADD_BLOCK(events, blk_orph_32); // 46
141 DO_CALLBACK(events, "check_orphaned_switched_to_main"); // 47
142
143 //check orphaned check to main chain
144 MAKE_NEXT_BLOCK_NO_ADD(events, blk_orph_39, blk_16, get_test_target(), first_miner_account);
145 MAKE_NEXT_BLOCK(events, blk_33, blk_orph_39, get_test_target(), first_miner_account); // 48
146 MAKE_NEXT_BLOCK(events, blk_34, blk_33, get_test_target(), first_miner_account); // 49
147 MAKE_NEXT_BLOCK_NO_ADD(events, blk_orph_41, blk_34, get_test_target(), first_miner_account);
148 MAKE_NEXT_BLOCK(events, blk_35, blk_orph_41, get_test_target(), first_miner_account); // 50
149 MAKE_NEXT_BLOCK(events, blk_36, blk_35, get_test_target(), first_miner_account); // 51
150 MAKE_NEXT_BLOCK_NO_ADD(events, blk_orph_40, blk_36, get_test_target(), first_miner_account);
151 MAKE_NEXT_BLOCK(events, blk_37, blk_orph_40, get_test_target(), first_miner_account); // 52
152 MAKE_NEXT_BLOCK(events, blk_38, blk_37, get_test_target(), first_miner_account); // 53
153 DO_CALLBACK(events, "check_orphaned_chain_38"); // 54
154 ADD_BLOCK(events, blk_orph_39); // 55
155 DO_CALLBACK(events, "check_orphaned_chain_39"); // 56
156 ADD_BLOCK(events, blk_orph_40); // 57
157 DO_CALLBACK(events, "check_orphaned_chain_40"); // 58
158 ADD_BLOCK(events, blk_orph_41); // 59
159 DO_CALLBACK(events, "check_orphaned_chain_41"); // 60
160 */
161 return true;
162}
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition chaingen.h:839
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition chaingen.h:890
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
Definition chaingen.h:833
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
Definition chaingen.h:820
#define MK_COINS(amount)
Definition chaingen.h:1060
#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD)
Definition chaingen.h:903
#define GENERATE_ACCOUNT(account)
Definition chaingen.h:801
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
Definition chaingen.h:849
unsigned __int64 uint64_t
Definition stdint.h:136

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/core_tests/chain_split_1.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/core_tests/chain_split_1.cpp