Electroneum
gen_uint_overflow_1 Struct Reference

#include <integer_overflow.h>

Inheritance diagram for gen_uint_overflow_1:
Collaboration diagram for gen_uint_overflow_1:

Public Member Functions

bool generate (std::vector< test_event_entry > &events) const
 
- Public Member Functions inherited from gen_uint_overflow_base
 gen_uint_overflow_base ()
 
bool check_tx_verification_context (const cryptonote::tx_verification_context &tvc, bool tx_added, size_t event_idx, const cryptonote::transaction &tx)
 
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &block)
 
bool mark_last_valid_block (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 48 of file integer_overflow.h.

Member Function Documentation

◆ generate()

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

Definition at line 100 of file integer_overflow.cpp.

101 {
102  uint64_t ts_start = 1338224400;
103 
104  GENERATE_ACCOUNT(miner_account);
105  MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start);
106  DO_CALLBACK(events, "mark_last_valid_block");
107  MAKE_ACCOUNT(events, bob_account);
108  MAKE_ACCOUNT(events, alice_account);
109 
110  // Problem 1. Miner tx output overflow
111  MAKE_MINER_TX_MANUALLY(miner_tx_0, blk_0);
112  split_miner_tx_outs(miner_tx_0, ETN_SUPPLY);
113  block blk_1;
114  if (!generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_miner_tx, 0, 0, 0, crypto::hash(), 0, miner_tx_0))
115  return false;
116  events.push_back(blk_1);
117 
118  // Problem 1. Miner tx outputs overflow
119  MAKE_MINER_TX_MANUALLY(miner_tx_1, blk_1);
120  split_miner_tx_outs(miner_tx_1, ETN_SUPPLY);
121  block blk_2;
122  if (!generator.construct_block_manually(blk_2, blk_1, miner_account, test_generator::bf_miner_tx, 0, 0, 0, crypto::hash(), 0, miner_tx_1))
123  return false;
124  events.push_back(blk_2);
125 
126  REWIND_BLOCKS(events, blk_2r, blk_2, miner_account);
127  MAKE_TX_LIST_START(events, txs_0, miner_account, bob_account, ETN_SUPPLY, blk_2);
128  MAKE_TX_LIST(events, txs_0, miner_account, bob_account, ETN_SUPPLY, blk_2);
129  MAKE_NEXT_BLOCK_TX_LIST(events, blk_3, blk_2r, miner_account, txs_0);
130  REWIND_BLOCKS(events, blk_3r, blk_3, miner_account);
131 
132  // Problem 2. total_fee overflow, block_reward overflow
133  std::list<cryptonote::transaction> txs_1;
134  // Create txs with huge fee
135  txs_1.push_back(construct_tx_with_fee(events, blk_3, bob_account, alice_account, MK_COINS(1), ETN_SUPPLY - MK_COINS(1)));
136  txs_1.push_back(construct_tx_with_fee(events, blk_3, bob_account, alice_account, MK_COINS(1), ETN_SUPPLY - MK_COINS(1)));
137  MAKE_NEXT_BLOCK_TX_LIST(events, blk_4, blk_3r, miner_account, txs_1);
138 
139  return true;
140 }
#define ETN_SUPPLY
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition: chaingen.h:933
transaction construct_tx_with_fee(std::vector< test_event_entry > &events, const block &blk_head, const account_base &acc_from, const var_addr_t &to, uint64_t amount, uint64_t fee)
Definition: chaingen.cpp:931
#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_MINER_TX_MANUALLY(TX, BLK)
Definition: chaingen.h:949
#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
POD_CLASS hash
Definition: hash.h:50
#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:

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