Electroneum
Loading...
Searching...
No Matches
chaingen.h File Reference
#include <vector>
#include <iostream>
#include <stdint.h>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/program_options.hpp>
#include <boost/optional.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/serialization/optional.hpp>
#include <boost/serialization/unordered_map.hpp>
#include <boost/functional/hash.hpp>
#include "include_base_utils.h"
#include "common/boost_serialization_helper.h"
#include "common/command_line.h"
#include "cryptonote_basic/account_boost_serialization.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_basic/cryptonote_boost_serialization.h"
#include "misc_language.h"
Include dependency graph for chaingen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  callback_entry
struct  serialized_object< T >
struct  event_visitor_settings
struct  event_replay_settings
class  test_chain_unit_base
class  test_generator
struct  test_generator::block_info
struct  output_index
struct  dest_wrapper_t
class  block_tracker
struct  push_core_event_visitor< t_test_class >
struct  get_test_options< t_test_class >

Macros

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "tests.core"
#define DEFAULT_HARDFORKS(HARDFORKS)
#define ADD_HARDFORK(HARDFORKS, FORK, HEIGHT)
#define GENERATE_ACCOUNT(account)
#define GENERATE_MULTISIG_ACCOUNT(account, threshold, total)
#define MAKE_ACCOUNT(VEC_EVENTS, account)
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
#define REGISTER_CALLBACK(CB_NAME, CLBACK)
#define REGISTER_CALLBACK_METHOD(CLASS, METHOD)
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
#define MAKE_NEXT_BLOCK_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF)
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
#define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF)
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
#define MAKE_NEXT_BLOCK_TX_LIST_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF)
#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF)
#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT)
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
#define REWIND_BLOCKS_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF)
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
#define MAKE_TX_MIX_RCT(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD)
#define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
#define MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
#define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER)
#define MAKE_TX_MIX_DEST_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD)
#define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER)
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
#define MAKE_TX_LIST_START_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY)
#define MAKE_MINER_TX_MANUALLY(TX, BLK)
#define SET_EVENT_VISITOR_SETT(VEC_EVENTS, SETT, VAL)
#define GENERATE(filename, genclass)
#define PLAY(filename, genclass)
#define CATCH_REPLAY(genclass)
#define REPLAY_CORE(genclass)
#define REPLAY_WITH_CORE(genclass, CORE)
#define CATCH_GENERATE_REPLAY(genclass)
#define CATCH_GENERATE_REPLAY_CORE(genclass, CORE)
#define GENERATE_AND_PLAY(genclass)
#define GENERATE_AND_PLAY_INSTANCE(genclass, ins, CORE)
#define CALL_TEST(test_name, function)
#define QUOTEME(x)
#define DEFINE_TESTS_ERROR_CONTEXT(text)
#define CHECK_TEST_CONDITION(cond)
#define CHECK_EQ(v1, v2)
#define CHECK_NOT_EQ(v1, v2)
#define MK_COINS(amount)
#define TESTS_DEFAULT_FEE   ((uint64_t)10)

Typedefs

typedef serialized_object< cryptonote::blockserialized_block
typedef serialized_object< cryptonote::transactionserialized_transaction
typedef std::vector< std::pair< uint8_t, uint64_t > > v_hardforks_t
typedef boost::variant< cryptonote::block, cryptonote::transaction, std::vector< cryptonote::transaction >, cryptonote::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_replay_settingstest_event_entry
typedef std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
typedef std::tuple< uint64_t, crypto::public_key, rct::keyget_outs_entry
typedef std::pair< crypto::hash, size_t > output_hasher
typedef boost::hash< output_hasheroutput_hasher_hasher
typedef std::map< uint64_t, std::vector< size_t > > map_output_t
typedef std::map< uint64_t, std::vector< output_index > > map_output_idx_t
typedef std::unordered_map< crypto::hash, cryptonote::blockmap_block_t
typedef std::unordered_map< output_hasher, output_index, output_hasher_hashermap_txid_output_t
typedef std::unordered_map< crypto::public_key, cryptonote::subaddress_indexsubaddresses_t
typedef std::pair< uint64_t, size_t > outloc_t
typedef boost::variant< cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entryvar_addr_t

Functions

 VARIANT_TAG (binary_archive, callback_entry, 0xcb)
 VARIANT_TAG (binary_archive, cryptonote::account_base, 0xcc)
 VARIANT_TAG (binary_archive, serialized_block, 0xcd)
 VARIANT_TAG (binary_archive, serialized_transaction, 0xce)
 VARIANT_TAG (binary_archive, event_visitor_settings, 0xcf)
 VARIANT_TAG (binary_archive, event_replay_settings, 0xda)
template<typename T>
std::string dump_keys (T *buff32)
std::string dump_data (const cryptonote::transaction &tx)
cryptonote::account_public_address get_address (const var_addr_t &inp)
cryptonote::account_public_address get_address (const cryptonote::account_public_address &inp)
cryptonote::account_public_address get_address (const cryptonote::account_keys &inp)
cryptonote::account_public_address get_address (const cryptonote::account_base &inp)
cryptonote::account_public_address get_address (const cryptonote::tx_destination_entry &inp)
cryptonote::difficulty_type get_test_difficulty (const boost::optional< uint8_t > &hf_ver=boost::none)
uint64_t current_difficulty_window (const boost::optional< uint8_t > &hf_ver=boost::none)
void fill_nonce (cryptonote::block &blk, const cryptonote::difficulty_type &diffic, uint64_t height)
cryptonote::tx_destination_entry build_dst (const var_addr_t &to, bool is_subaddr=false, uint64_t amount=0)
std::vector< cryptonote::tx_destination_entrybuild_dsts (const var_addr_t &to1, bool sub1=false, uint64_t am1=0)
std::vector< cryptonote::tx_destination_entrybuild_dsts (std::initializer_list< dest_wrapper_t > inps)
uint64_t sum_amount (const std::vector< cryptonote::tx_destination_entry > &destinations)
uint64_t sum_amount (const std::vector< cryptonote::tx_source_entry > &sources)
bool construct_miner_tx_manually (size_t height, uint64_t already_generated_coins, const cryptonote::account_public_address &miner_address, cryptonote::transaction &tx, uint64_t fee, cryptonote::keypair *p_txkey=nullptr)
bool construct_tx_to_key (const std::vector< test_event_entry > &events, cryptonote::transaction &tx, const cryptonote::block &blk_head, const cryptonote::account_base &from, const var_addr_t &to, uint64_t amount, uint64_t fee, size_t nmix, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
bool construct_tx_to_key (const std::vector< test_event_entry > &events, cryptonote::transaction &tx, const cryptonote::block &blk_head, const cryptonote::account_base &from, std::vector< cryptonote::tx_destination_entry > destinations, uint64_t fee, size_t nmix, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
bool construct_tx_to_key (cryptonote::transaction &tx, const cryptonote::account_base &from, const var_addr_t &to, uint64_t amount, std::vector< cryptonote::tx_source_entry > &sources, uint64_t fee, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
bool construct_tx_to_key (cryptonote::transaction &tx, const cryptonote::account_base &from, const std::vector< cryptonote::tx_destination_entry > &destinations, std::vector< cryptonote::tx_source_entry > &sources, uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version=0)
cryptonote::transaction construct_tx_with_fee (std::vector< test_event_entry > &events, const cryptonote::block &blk_head, const cryptonote::account_base &acc_from, const var_addr_t &to, uint64_t amount, uint64_t fee)
bool construct_tx_rct (const cryptonote::account_keys &sender_account_keys, std::vector< cryptonote::tx_source_entry > &sources, const std::vector< cryptonote::tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, std::vector< uint8_t > extra, cryptonote::transaction &tx, uint64_t unlock_time, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
uint64_t num_blocks (const std::vector< test_event_entry > &events)
cryptonote::block get_head_block (const std::vector< test_event_entry > &events)
void get_confirmed_txs (const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, map_hash2tx_t &confirmed_txs)
bool trim_block_chain (std::vector< cryptonote::block > &blockchain, const crypto::hash &tail)
bool trim_block_chain (std::vector< const cryptonote::block * > &blockchain, const crypto::hash &tail)
bool find_block_chain (const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
bool find_block_chain (const std::vector< test_event_entry > &events, std::vector< const cryptonote::block * > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
void fill_tx_destinations (const var_addr_t &from, const cryptonote::account_public_address &to, uint64_t amount, uint64_t fee, const std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations, bool always_change=false)
void fill_tx_destinations (const var_addr_t &from, const std::vector< cryptonote::tx_destination_entry > &dests, uint64_t fee, const std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations, bool always_change)
void fill_tx_destinations (const var_addr_t &from, const cryptonote::account_public_address &to, uint64_t amount, uint64_t fee, const std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations, std::vector< cryptonote::tx_destination_entry > &destinations_pure, bool always_change=false)
void fill_tx_sources_and_destinations (const std::vector< test_event_entry > &events, const cryptonote::block &blk_head, const cryptonote::account_base &from, const cryptonote::account_public_address &to, uint64_t amount, uint64_t fee, size_t nmix, std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations)
void fill_tx_sources_and_destinations (const std::vector< test_event_entry > &events, const cryptonote::block &blk_head, const cryptonote::account_base &from, const cryptonote::account_base &to, uint64_t amount, uint64_t fee, size_t nmix, std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations)
uint64_t get_balance (const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
bool extract_hard_forks (const std::vector< test_event_entry > &events, v_hardforks_t &hard_forks)
template<class t_test_class>
bool replay_events_through_core (cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator)
template<class t_test_class>
bool replay_events_through_core_plain (cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator, bool reinit=true)
template<class t_test_class>
bool do_replay_events_get_core (std::vector< test_event_entry > &events, cryptonote::core *core)
template<class t_test_class>
bool replay_events_through_core_validate (std::vector< test_event_entry > &events, cryptonote::core &c)
template<class t_test_class>
bool do_replay_events (std::vector< test_event_entry > &events)
template<class t_test_class>
bool do_replay_file (const std::string &filename)

Macro Definition Documentation

◆ ADD_HARDFORK

#define ADD_HARDFORK ( HARDFORKS,
FORK,
HEIGHT )
Value:
HARDFORKS.push_back(std::make_pair((uint8_t)FORK, (uint64_t)HEIGHT))
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136

Definition at line 799 of file chaingen.h.

◆ CALL_TEST

#define CALL_TEST ( test_name,
function )
Value:
{ \
if(!function()) \
{ \
MERROR("#TEST# Failed " << test_name); \
return 1; \
} \
else \
{ \
MGINFO_GREEN("#TEST# Succeeded " << test_name); \
} \
}

Definition at line 1042 of file chaingen.h.

1042#define CALL_TEST(test_name, function) \
1043 { \
1044 if(!function()) \
1045 { \
1046 MERROR("#TEST# Failed " << test_name); \
1047 return 1; \
1048 } \
1049 else \
1050 { \
1051 MGINFO_GREEN("#TEST# Succeeded " << test_name); \
1052 } \
1053 }

◆ CATCH_GENERATE_REPLAY

#define CATCH_GENERATE_REPLAY ( genclass)
Value:
CATCH_REPLAY(genclass); \
REPLAY_CORE(genclass);
#define CATCH_REPLAY(genclass)
Definition chaingen.h:973

Definition at line 1005 of file chaingen.h.

1005#define CATCH_GENERATE_REPLAY(genclass) \
1006 CATCH_REPLAY(genclass); \
1007 REPLAY_CORE(genclass);

◆ CATCH_GENERATE_REPLAY_CORE

#define CATCH_GENERATE_REPLAY_CORE ( genclass,
CORE )
Value:
CATCH_REPLAY(genclass); \
REPLAY_WITH_CORE(genclass, CORE);

Definition at line 1009 of file chaingen.h.

1009#define CATCH_GENERATE_REPLAY_CORE(genclass, CORE) \
1010 CATCH_REPLAY(genclass); \
1011 REPLAY_WITH_CORE(genclass, CORE);

◆ CATCH_REPLAY

#define CATCH_REPLAY ( genclass)
Value:
catch (const std::exception& ex) \
{ \
MERROR(#genclass << " generation failed: what=" << ex.what()); \
} \
catch (...) \
{ \
MERROR(#genclass << " generation failed: generic exception"); \
}

Definition at line 973 of file chaingen.h.

973#define CATCH_REPLAY(genclass) \
974 catch (const std::exception& ex) \
975 { \
976 MERROR(#genclass << " generation failed: what=" << ex.what()); \
977 } \
978 catch (...) \
979 { \
980 MERROR(#genclass << " generation failed: generic exception"); \
981 }

◆ CHECK_EQ

#define CHECK_EQ ( v1,
v2 )
Value:
CHECK_AND_ASSERT_MES(v1 == v2, false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " == " << QUOTEME(v2) << "\", " << v1 << " != " << v2)
#define QUOTEME(x)
Definition chaingen.h:1055
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)

Definition at line 1058 of file chaingen.h.

◆ CHECK_NOT_EQ

#define CHECK_NOT_EQ ( v1,
v2 )
Value:
CHECK_AND_ASSERT_MES(!(v1 == v2), false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " != " << QUOTEME(v2) << "\", " << v1 << " == " << v2)

Definition at line 1059 of file chaingen.h.

◆ CHECK_TEST_CONDITION

#define CHECK_TEST_CONDITION ( cond)
Value:
CHECK_AND_ASSERT_MES(cond, false, "[" << perr_context << "] failed: \"" << QUOTEME(cond) << "\"")

Definition at line 1057 of file chaingen.h.

◆ DEFAULT_HARDFORKS

#define DEFAULT_HARDFORKS ( HARDFORKS)
Value:
do { \
HARDFORKS.push_back(std::make_pair((uint8_t)1, (uint64_t)0)); \
} while(0)

Definition at line 795 of file chaingen.h.

795#define DEFAULT_HARDFORKS(HARDFORKS) do { \
796 HARDFORKS.push_back(std::make_pair((uint8_t)1, (uint64_t)0)); \
797} while(0)

◆ DEFINE_TESTS_ERROR_CONTEXT

#define DEFINE_TESTS_ERROR_CONTEXT ( text)
Value:
const char* perr_context = text;

Definition at line 1056 of file chaingen.h.

◆ DO_CALLBACK

#define DO_CALLBACK ( VEC_EVENTS,
CB_NAME )
Value:
{ \
callback_entry CALLBACK_ENTRY; \
CALLBACK_ENTRY.callback_name = CB_NAME; \
VEC_EVENTS.push_back(CALLBACK_ENTRY); \
}
Definition chaingen.h:66
std::string callback_name
Definition chaingen.h:67

Definition at line 820 of file chaingen.h.

820#define DO_CALLBACK(VEC_EVENTS, CB_NAME) \
821{ \
822 callback_entry CALLBACK_ENTRY; \
823 CALLBACK_ENTRY.callback_name = CB_NAME; \
824 VEC_EVENTS.push_back(CALLBACK_ENTRY); \
825}

◆ ELECTRONEUM_DEFAULT_LOG_CATEGORY

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "tests.core"

Definition at line 61 of file chaingen.h.

◆ GENERATE

#define GENERATE ( filename,
genclass )
Value:
{ \
std::vector<test_event_entry> events; \
genclass g; \
g.generate(events); \
if (!tools::serialize_obj_to_file(events, filename)) \
{ \
MERROR("Failed to serialize data to file: " << filename); \
throw std::runtime_error("Failed to serialize data to file"); \
} \
}
bool serialize_obj_to_file(t_object &obj, const std::string &file_path)

Definition at line 953 of file chaingen.h.

953#define GENERATE(filename, genclass) \
954 { \
955 std::vector<test_event_entry> events; \
956 genclass g; \
957 g.generate(events); \
958 if (!tools::serialize_obj_to_file(events, filename)) \
959 { \
960 MERROR("Failed to serialize data to file: " << filename); \
961 throw std::runtime_error("Failed to serialize data to file"); \
962 } \
963 }

◆ GENERATE_ACCOUNT

#define GENERATE_ACCOUNT ( account)
Value:
account.generate();
crypto::secret_key generate(const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false, bool two_random=false)
Definition account.cpp:158

Definition at line 801 of file chaingen.h.

801#define GENERATE_ACCOUNT(account) \
802 cryptonote::account_base account; \
803 account.generate();

◆ GENERATE_AND_PLAY

#define GENERATE_AND_PLAY ( genclass)
Value:
if (list_tests) \
std::cout << #genclass << std::endl; \
else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
{ \
std::vector<test_event_entry> events; \
++tests_count; \
bool generated = false; \
try \
{ \
genclass g; \
generated = g.generate(events); \
} \
CATCH_GENERATE_REPLAY(genclass); \
}

Definition at line 1013 of file chaingen.h.

1013#define GENERATE_AND_PLAY(genclass) \
1014 if (list_tests) \
1015 std::cout << #genclass << std::endl; \
1016 else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1017 { \
1018 std::vector<test_event_entry> events; \
1019 ++tests_count; \
1020 bool generated = false; \
1021 try \
1022 { \
1023 genclass g; \
1024 generated = g.generate(events); \
1025 } \
1026 CATCH_GENERATE_REPLAY(genclass); \
1027 }

◆ GENERATE_AND_PLAY_INSTANCE

#define GENERATE_AND_PLAY_INSTANCE ( genclass,
ins,
CORE )
Value:
if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
{ \
std::vector<test_event_entry> events; \
++tests_count; \
bool generated = false; \
try \
{ \
generated = ins.generate(events); \
} \
CATCH_GENERATE_REPLAY_CORE(genclass, CORE); \
}

Definition at line 1029 of file chaingen.h.

1029#define GENERATE_AND_PLAY_INSTANCE(genclass, ins, CORE) \
1030 if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1031 { \
1032 std::vector<test_event_entry> events; \
1033 ++tests_count; \
1034 bool generated = false; \
1035 try \
1036 { \
1037 generated = ins.generate(events); \
1038 } \
1039 CATCH_GENERATE_REPLAY_CORE(genclass, CORE); \
1040 }

◆ GENERATE_MULTISIG_ACCOUNT

#define GENERATE_MULTISIG_ACCOUNT ( account,
threshold,
total )
Value:
CHECK_AND_ASSERT_MES(threshold >= 2 && threshold <= total, false, "Invalid multisig scheme"); \
std::vector<cryptonote::account_base> account(total); \
do \
{ \
for (size_t msidx = 0; msidx < total; ++msidx) \
account[msidx].generate(); \
make_multisig_accounts(account, threshold); \
} while(0)
uint8_t threshold

Definition at line 805 of file chaingen.h.

805#define GENERATE_MULTISIG_ACCOUNT(account, threshold, total) \
806 CHECK_AND_ASSERT_MES(threshold >= 2 && threshold <= total, false, "Invalid multisig scheme"); \
807 std::vector<cryptonote::account_base> account(total); \
808 do \
809 { \
810 for (size_t msidx = 0; msidx < total; ++msidx) \
811 account[msidx].generate(); \
812 make_multisig_accounts(account, threshold); \
813 } while(0)

◆ MAKE_ACCOUNT

#define MAKE_ACCOUNT ( VEC_EVENTS,
account )
Value:
account.generate(); \
VEC_EVENTS.push_back(account);

Definition at line 815 of file chaingen.h.

815#define MAKE_ACCOUNT(VEC_EVENTS, account) \
816 cryptonote::account_base account; \
817 account.generate(); \
818 VEC_EVENTS.push_back(account);

◆ MAKE_GENESIS_BLOCK

#define MAKE_GENESIS_BLOCK ( VEC_EVENTS,
BLK_NAME,
MINER_ACC,
TS )
Value:
test_generator generator; \
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, MINER_ACC, TS); \
VEC_EVENTS.push_back(BLK_NAME);
bool construct_block(cryptonote::block &blk, uint64_t height, const crypto::hash &prev_id, const cryptonote::account_base &miner_acc, uint64_t timestamp, uint64_t already_generated_coins, std::vector< size_t > &block_weights, const std::list< cryptonote::transaction > &tx_list, const boost::optional< uint8_t > &hf_ver=boost::none)
Definition chaingen.cpp:112

Definition at line 833 of file chaingen.h.

833#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS) \
834 test_generator generator; \
835 cryptonote::block BLK_NAME; \
836 generator.construct_block(BLK_NAME, MINER_ACC, TS); \
837 VEC_EVENTS.push_back(BLK_NAME);

◆ MAKE_MINER_TX_AND_KEY_MANUALLY

#define MAKE_MINER_TX_AND_KEY_MANUALLY ( TX,
BLK,
KEY )
Value:
transaction TX; \
if (!construct_miner_tx_manually(get_block_height(BLK) + 1, generator.get_already_generated_coins(BLK), \
miner_account.get_keys().m_account_address, TX, 0, KEY)) \
return false;
bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins, const account_public_address &miner_address, transaction &tx, uint64_t fee, keypair *p_txkey)
Definition chaingen.cpp:830

Definition at line 943 of file chaingen.h.

943#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY) \
944 transaction TX; \
945 if (!construct_miner_tx_manually(get_block_height(BLK) + 1, generator.get_already_generated_coins(BLK), \
946 miner_account.get_keys().m_account_address, TX, 0, KEY)) \
947 return false;

◆ MAKE_MINER_TX_MANUALLY

#define MAKE_MINER_TX_MANUALLY ( TX,
BLK )
Value:
#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY)
Definition chaingen.h:943

Definition at line 949 of file chaingen.h.

◆ MAKE_NEXT_BLOCK

#define MAKE_NEXT_BLOCK ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC )
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 839 of file chaingen.h.

839#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC) \
840 cryptonote::block BLK_NAME; \
841 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC); \
842 VEC_EVENTS.push_back(BLK_NAME);

◆ MAKE_NEXT_BLOCK_HF

#define MAKE_NEXT_BLOCK_HF ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
HF )
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, std::list<cryptonote::transaction>(), HF); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 844 of file chaingen.h.

844#define MAKE_NEXT_BLOCK_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF) \
845 cryptonote::block BLK_NAME; \
846 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, std::list<cryptonote::transaction>(), HF); \
847 VEC_EVENTS.push_back(BLK_NAME);

◆ MAKE_NEXT_BLOCK_TX1

#define MAKE_NEXT_BLOCK_TX1 ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
TX1 )
Value:
cryptonote::block BLK_NAME; \
{ \
std::list<cryptonote::transaction> tx_list; \
tx_list.push_back(TX1); \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list); \
} \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 849 of file chaingen.h.

849#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1) \
850 cryptonote::block BLK_NAME; \
851 { \
852 std::list<cryptonote::transaction> tx_list; \
853 tx_list.push_back(TX1); \
854 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list); \
855 } \
856 VEC_EVENTS.push_back(BLK_NAME);

◆ MAKE_NEXT_BLOCK_TX1_HF

#define MAKE_NEXT_BLOCK_TX1_HF ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
TX1,
HF )
Value:
cryptonote::block BLK_NAME; \
{ \
std::list<cryptonote::transaction> tx_list; \
tx_list.push_back(TX1); \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list, HF); \
} \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 858 of file chaingen.h.

858#define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF) \
859 cryptonote::block BLK_NAME; \
860 { \
861 std::list<cryptonote::transaction> tx_list; \
862 tx_list.push_back(TX1); \
863 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list, HF); \
864 } \
865 VEC_EVENTS.push_back(BLK_NAME);

◆ MAKE_NEXT_BLOCK_TX_LIST

#define MAKE_NEXT_BLOCK_TX_LIST ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
TXLIST )
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 867 of file chaingen.h.

867#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST) \
868 cryptonote::block BLK_NAME; \
869 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST); \
870 VEC_EVENTS.push_back(BLK_NAME);

◆ MAKE_NEXT_BLOCK_TX_LIST_HF

#define MAKE_NEXT_BLOCK_TX_LIST_HF ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
TXLIST,
HF )
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 872 of file chaingen.h.

872#define MAKE_NEXT_BLOCK_TX_LIST_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF) \
873 cryptonote::block BLK_NAME; \
874 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF); \
875 VEC_EVENTS.push_back(BLK_NAME);

◆ MAKE_TX

#define MAKE_TX ( VEC_EVENTS,
TX_NAME,
FROM,
TO,
AMOUNT,
HEAD )
Value:
MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, 0, HEAD)
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
Definition chaingen.h:893

Definition at line 903 of file chaingen.h.

◆ MAKE_TX_LIST

#define MAKE_TX_LIST ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
AMOUNT,
HEAD )
Value:
MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, 0, HEAD)
#define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
Definition chaingen.h:905

Definition at line 933 of file chaingen.h.

◆ MAKE_TX_LIST_START

#define MAKE_TX_LIST_START ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
AMOUNT,
HEAD )
Value:
std::list<cryptonote::transaction> SET_NAME; \
MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD);

Definition at line 935 of file chaingen.h.

935#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD) \
936 std::list<cryptonote::transaction> SET_NAME; \
937 MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD);

◆ MAKE_TX_LIST_START_RCT

#define MAKE_TX_LIST_START_RCT ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
AMOUNT,
NMIX,
HEAD )
Value:
std::list<cryptonote::transaction> SET_NAME; \
MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD);

Definition at line 939 of file chaingen.h.

939#define MAKE_TX_LIST_START_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
940 std::list<cryptonote::transaction> SET_NAME; \
941 MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD);

◆ MAKE_TX_MIX

#define MAKE_TX_MIX ( VEC_EVENTS,
TX_NAME,
FROM,
TO,
AMOUNT,
NMIX,
HEAD )
Value:
construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
VEC_EVENTS.push_back(TX_NAME);
#define TESTS_DEFAULT_FEE
Definition chaingen.h:1061

Definition at line 893 of file chaingen.h.

893#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
894 cryptonote::transaction TX_NAME; \
895 construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
896 VEC_EVENTS.push_back(TX_NAME);

◆ MAKE_TX_MIX_DEST_LIST_RCT

#define MAKE_TX_MIX_DEST_LIST_RCT ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
NMIX,
HEAD )
Value:
MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
#define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER)
Definition chaingen.h:925
@ RangeProofPaddedBulletproof
Definition rctTypes.h:235

Definition at line 923 of file chaingen.h.

923#define MAKE_TX_MIX_DEST_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD) \
924 MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)

◆ MAKE_TX_MIX_DEST_LIST_RCT_EX

#define MAKE_TX_MIX_DEST_LIST_RCT_EX ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
NMIX,
HEAD,
RCT_TYPE,
BP_VER )
Value:
{ \
construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
SET_NAME.push_back(t); \
VEC_EVENTS.push_back(t); \
}

Definition at line 925 of file chaingen.h.

925#define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER) \
926 { \
927 cryptonote::transaction t; \
928 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
929 SET_NAME.push_back(t); \
930 VEC_EVENTS.push_back(t); \
931 }

◆ MAKE_TX_MIX_LIST

#define MAKE_TX_MIX_LIST ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
AMOUNT,
NMIX,
HEAD )
Value:
{ \
construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
SET_NAME.push_back(t); \
VEC_EVENTS.push_back(t); \
}

Definition at line 905 of file chaingen.h.

905#define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
906 { \
907 cryptonote::transaction t; \
908 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
909 SET_NAME.push_back(t); \
910 VEC_EVENTS.push_back(t); \
911 }

◆ MAKE_TX_MIX_LIST_RCT

#define MAKE_TX_MIX_LIST_RCT ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
AMOUNT,
NMIX,
HEAD )
Value:
MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
#define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER)
Definition chaingen.h:915

Definition at line 913 of file chaingen.h.

913#define MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
914 MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)

◆ MAKE_TX_MIX_LIST_RCT_EX

#define MAKE_TX_MIX_LIST_RCT_EX ( VEC_EVENTS,
SET_NAME,
FROM,
TO,
AMOUNT,
NMIX,
HEAD,
RCT_TYPE,
BP_VER )
Value:
{ \
construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
SET_NAME.push_back(t); \
VEC_EVENTS.push_back(t); \
}

Definition at line 915 of file chaingen.h.

915#define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER) \
916 { \
917 cryptonote::transaction t; \
918 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
919 SET_NAME.push_back(t); \
920 VEC_EVENTS.push_back(t); \
921 }

◆ MAKE_TX_MIX_RCT

#define MAKE_TX_MIX_RCT ( VEC_EVENTS,
TX_NAME,
FROM,
TO,
AMOUNT,
NMIX,
HEAD )
Value:
construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, rct::RangeProofPaddedBulletproof); \
VEC_EVENTS.push_back(TX_NAME);

Definition at line 898 of file chaingen.h.

898#define MAKE_TX_MIX_RCT(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
899 cryptonote::transaction TX_NAME; \
900 construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, rct::RangeProofPaddedBulletproof); \
901 VEC_EVENTS.push_back(TX_NAME);

◆ MK_COINS

#define MK_COINS ( amount)
Value:
(UINT64_C(amount) * COIN)
#define COIN
#define UINT64_C(val)
Definition stdint.h:284

Definition at line 1060 of file chaingen.h.

◆ PLAY

#define PLAY ( filename,
genclass )
Value:
if(!do_replay_file<genclass>(filename)) \
{ \
MERROR("Failed to pass test : " << #genclass); \
return 1; \
}
bool do_replay_file(const std::string &filename)
Definition chaingen.h:783

Definition at line 966 of file chaingen.h.

966#define PLAY(filename, genclass) \
967 if(!do_replay_file<genclass>(filename)) \
968 { \
969 MERROR("Failed to pass test : " << #genclass); \
970 return 1; \
971 }

◆ QUOTEME

#define QUOTEME ( x)
Value:
#x

Definition at line 1055 of file chaingen.h.

◆ REGISTER_CALLBACK

#define REGISTER_CALLBACK ( CB_NAME,
CLBACK )
Value:
register_callback(CB_NAME, std::bind(&CLBACK, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

Definition at line 827 of file chaingen.h.

827#define REGISTER_CALLBACK(CB_NAME, CLBACK) \
828 register_callback(CB_NAME, std::bind(&CLBACK, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

◆ REGISTER_CALLBACK_METHOD

#define REGISTER_CALLBACK_METHOD ( CLASS,
METHOD )
Value:
register_callback(#METHOD, std::bind(&CLASS::METHOD, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

Definition at line 830 of file chaingen.h.

830#define REGISTER_CALLBACK_METHOD(CLASS, METHOD) \
831 register_callback(#METHOD, std::bind(&CLASS::METHOD, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

◆ REPLAY_CORE

#define REPLAY_CORE ( genclass)
Value:
if (generated && do_replay_events< genclass >(events)) \
{ \
MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
} \
else \
{ \
MERROR("#TEST# Failed " << #genclass); \
failed_tests.push_back(#genclass); \
}
bool do_replay_events(std::vector< test_event_entry > &events)
Definition chaingen.h:774

Definition at line 983 of file chaingen.h.

983#define REPLAY_CORE(genclass) \
984 if (generated && do_replay_events< genclass >(events)) \
985 { \
986 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
987 } \
988 else \
989 { \
990 MERROR("#TEST# Failed " << #genclass); \
991 failed_tests.push_back(#genclass); \
992 }

◆ REPLAY_WITH_CORE

#define REPLAY_WITH_CORE ( genclass,
CORE )
Value:
if (generated && replay_events_through_core_validate< genclass >(events, CORE)) \
{ \
MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
} \
else \
{ \
MERROR("#TEST# Failed " << #genclass); \
failed_tests.push_back(#genclass); \
}
bool replay_events_through_core_validate(std::vector< test_event_entry > &events, cryptonote::core &c)
Definition chaingen.h:759

Definition at line 994 of file chaingen.h.

994#define REPLAY_WITH_CORE(genclass, CORE) \
995 if (generated && replay_events_through_core_validate< genclass >(events, CORE)) \
996 { \
997 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
998 } \
999 else \
1000 { \
1001 MERROR("#TEST# Failed " << #genclass); \
1002 failed_tests.push_back(#genclass); \
1003 }

◆ REWIND_BLOCKS

#define REWIND_BLOCKS ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC )
Value:
REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW)
#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT)
Definition chaingen.h:889
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW

Definition at line 890 of file chaingen.h.

◆ REWIND_BLOCKS_HF

#define REWIND_BLOCKS_HF ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
HF )
Value:
REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, HF)
#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF)
Definition chaingen.h:877

Definition at line 891 of file chaingen.h.

◆ REWIND_BLOCKS_N

#define REWIND_BLOCKS_N ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
COUNT )
Value:
REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, boost::none)

Definition at line 889 of file chaingen.h.

◆ REWIND_BLOCKS_N_HF

#define REWIND_BLOCKS_N_HF ( VEC_EVENTS,
BLK_NAME,
PREV_BLOCK,
MINER_ACC,
COUNT,
HF )
Value:
cryptonote::block BLK_NAME; \
{ \
cryptonote::block blk_last = PREV_BLOCK; \
for (size_t i = 0; i < COUNT; ++i) \
{ \
MAKE_NEXT_BLOCK_HF(VEC_EVENTS, blk, blk_last, MINER_ACC, HF); \
blk_last = blk; \
} \
BLK_NAME = blk_last; \
}

Definition at line 877 of file chaingen.h.

877#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF) \
878 cryptonote::block BLK_NAME; \
879 { \
880 cryptonote::block blk_last = PREV_BLOCK; \
881 for (size_t i = 0; i < COUNT; ++i) \
882 { \
883 MAKE_NEXT_BLOCK_HF(VEC_EVENTS, blk, blk_last, MINER_ACC, HF); \
884 blk_last = blk; \
885 } \
886 BLK_NAME = blk_last; \
887 }

◆ SET_EVENT_VISITOR_SETT

#define SET_EVENT_VISITOR_SETT ( VEC_EVENTS,
SETT,
VAL )
Value:
VEC_EVENTS.push_back(event_visitor_settings(SETT, VAL));

Definition at line 951 of file chaingen.h.

◆ TESTS_DEFAULT_FEE

#define TESTS_DEFAULT_FEE   ((uint64_t)10)

Definition at line 1061 of file chaingen.h.

Typedef Documentation

◆ get_outs_entry

Definition at line 352 of file chaingen.h.

◆ map_block_t

typedef std::unordered_map<crypto::hash, cryptonote::block> map_block_t

Definition at line 357 of file chaingen.h.

◆ map_hash2tx_t

typedef std::unordered_map<crypto::hash, const cryptonote::transaction*> map_hash2tx_t

Definition at line 163 of file chaingen.h.

◆ map_output_idx_t

typedef std::map<uint64_t, std::vector<output_index> > map_output_idx_t

Definition at line 356 of file chaingen.h.

◆ map_output_t

typedef std::map<uint64_t, std::vector<size_t> > map_output_t

Definition at line 355 of file chaingen.h.

◆ map_txid_output_t

Definition at line 358 of file chaingen.h.

◆ outloc_t

typedef std::pair<uint64_t, size_t> outloc_t

Definition at line 360 of file chaingen.h.

◆ output_hasher

typedef std::pair<crypto::hash, size_t> output_hasher

Definition at line 353 of file chaingen.h.

◆ output_hasher_hasher

typedef boost::hash<output_hasher> output_hasher_hasher

Definition at line 354 of file chaingen.h.

◆ serialized_block

Definition at line 107 of file chaingen.h.

◆ serialized_transaction

◆ subaddresses_t

Definition at line 359 of file chaingen.h.

◆ test_event_entry

◆ v_hardforks_t

typedef std::vector<std::pair<uint8_t, uint64_t> > v_hardforks_t

Definition at line 137 of file chaingen.h.

◆ var_addr_t

Function Documentation

◆ build_dst()

cryptonote::tx_destination_entry build_dst ( const var_addr_t & to,
bool is_subaddr = false,
uint64_t amount = 0 )

◆ build_dsts() [1/2]

std::vector< cryptonote::tx_destination_entry > build_dsts ( const var_addr_t & to1,
bool sub1 = false,
uint64_t am1 = 0 )

◆ build_dsts() [2/2]

std::vector< cryptonote::tx_destination_entry > build_dsts ( std::initializer_list< dest_wrapper_t > inps)

Definition at line 820 of file chaingen.cpp.

821{
822 std::vector<cryptonote::tx_destination_entry> res;
823 res.reserve(inps.size());
824 for(auto & c : inps){
825 res.push_back(build_dst(c.addr, c.is_subaddr, c.amount));
826 }
827 return res;
828}
cryptonote::tx_destination_entry build_dst(const var_addr_t &to, bool is_subaddr, uint64_t amount)
Definition chaingen.cpp:804
const char * res
Here is the call graph for this function:

◆ construct_miner_tx_manually()

bool construct_miner_tx_manually ( size_t height,
uint64_t already_generated_coins,
const cryptonote::account_public_address & miner_address,
cryptonote::transaction & tx,
uint64_t fee,
cryptonote::keypair * p_txkey = nullptr )

Definition at line 830 of file chaingen.cpp.

833{
834 keypair txkey;
835 txkey = keypair::generate(hw::get_device("default"));
836 add_tx_pub_key_to_extra(tx, txkey.pub);
837
838 if (0 != p_txkey)
839 *p_txkey = txkey;
840
841 txin_gen in;
842 in.height = height;
843 tx.vin.push_back(in);
844
845 // This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
846 uint64_t block_reward;
847 //Deal with premine implementation.
848 if (height == 1){block_reward = 1260000000000;}
849 else if (!get_block_reward(0, 0, already_generated_coins, block_reward, 1, height))
850 {
851 LOG_PRINT_L0("Block is too big");
852 return false;
853 }
854 block_reward += fee;
855
856 crypto::key_derivation derivation;
857 crypto::public_key out_eph_public_key;
858 crypto::generate_key_derivation(miner_address.m_view_public_key, txkey.sec, derivation);
859 crypto::derive_public_key(derivation, 0, miner_address.m_spend_public_key, out_eph_public_key);
860
861 tx_out out;
862 out.amount = block_reward;
863 out.target = txout_to_key(out_eph_public_key);
864 tx.vout.push_back(out);
865
866 tx.version = 1;
868
869 return true;
870}
uint64_t height
#define LOG_PRINT_L0(x)
Definition misc_log_ex.h:99
POD_CLASS key_derivation
Definition crypto.h:101
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
Definition crypto.h:272
POD_CLASS public_key
Definition crypto.h:79
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
Definition crypto.h:275
bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version, uint64_t current_block_height, network_type nettype)
bool add_tx_pub_key_to_extra(transaction &tx, const crypto::public_key &tx_pub_key)
device & get_device(const std::string &device_descriptor)
Definition device.cpp:95
crypto::secret_key sec
crypto::public_key pub
Here is the call graph for this function:

◆ construct_tx_rct()

bool construct_tx_rct ( const cryptonote::account_keys & sender_account_keys,
std::vector< cryptonote::tx_source_entry > & sources,
const std::vector< cryptonote::tx_destination_entry > & destinations,
const boost::optional< cryptonote::account_public_address > & change_addr,
std::vector< uint8_t > extra,
cryptonote::transaction & tx,
uint64_t unlock_time,
bool rct = false,
rct::RangeProofType range_proof_type = rct::RangeProofBorromean,
int bp_version = 0 )

◆ construct_tx_to_key() [1/4]

bool construct_tx_to_key ( const std::vector< test_event_entry > & events,
cryptonote::transaction & tx,
const cryptonote::block & blk_head,
const cryptonote::account_base & from,
const var_addr_t & to,
uint64_t amount,
uint64_t fee,
size_t nmix,
bool rct = false,
rct::RangeProofType range_proof_type = rct::RangeProofBorromean,
int bp_version = 0 )

◆ construct_tx_to_key() [2/4]

bool construct_tx_to_key ( const std::vector< test_event_entry > & events,
cryptonote::transaction & tx,
const cryptonote::block & blk_head,
const cryptonote::account_base & from,
std::vector< cryptonote::tx_destination_entry > destinations,
uint64_t fee,
size_t nmix,
bool rct = false,
rct::RangeProofType range_proof_type = rct::RangeProofBorromean,
int bp_version = 0 )

◆ construct_tx_to_key() [3/4]

bool construct_tx_to_key ( cryptonote::transaction & tx,
const cryptonote::account_base & from,
const std::vector< cryptonote::tx_destination_entry > & destinations,
std::vector< cryptonote::tx_source_entry > & sources,
uint64_t fee,
bool rct,
rct::RangeProofType range_proof_type,
int bp_version = 0 )

◆ construct_tx_to_key() [4/4]

bool construct_tx_to_key ( cryptonote::transaction & tx,
const cryptonote::account_base & from,
const var_addr_t & to,
uint64_t amount,
std::vector< cryptonote::tx_source_entry > & sources,
uint64_t fee,
bool rct = false,
rct::RangeProofType range_proof_type = rct::RangeProofBorromean,
int bp_version = 0 )

◆ construct_tx_with_fee()

cryptonote::transaction construct_tx_with_fee ( std::vector< test_event_entry > & events,
const cryptonote::block & blk_head,
const cryptonote::account_base & acc_from,
const var_addr_t & to,
uint64_t amount,
uint64_t fee )

Definition at line 931 of file chaingen.cpp.

933{
934 transaction tx;
935 construct_tx_to_key(events, tx, blk_head, acc_from, to, amount, fee, 0);
936 events.push_back(tx);
937 return tx;
938}
bool construct_tx_to_key(const std::vector< test_event_entry > &events, cryptonote::transaction &tx, const cryptonote::block &blk_head, const cryptonote::account_base &from, const var_addr_t &to, uint64_t amount, uint64_t fee, size_t nmix, bool rct, rct::RangeProofType range_proof_type, int bp_version)
Definition chaingen.cpp:872
Here is the call graph for this function:
Here is the caller graph for this function:

◆ current_difficulty_window()

uint64_t current_difficulty_window ( const boost::optional< uint8_t > & hf_ver = boost::none)
inline

Definition at line 410 of file chaingen.h.

410{ return !hf_ver || hf_ver.get() <= 1 ? DIFFICULTY_TARGET : DIFFICULTY_TARGET_V6; }
#define DIFFICULTY_TARGET
#define DIFFICULTY_TARGET_V6
Here is the caller graph for this function:

◆ do_replay_events()

template<class t_test_class>
bool do_replay_events ( std::vector< test_event_entry > & events)
inline

Definition at line 774 of file chaingen.h.

775{
776 cryptonote::core core(nullptr);
777 bool ret = do_replay_events_get_core<t_test_class>(events, &core);
778 core.deinit();
779 return ret;
780}
bool do_replay_events_get_core(std::vector< test_event_entry > &events, cryptonote::core *core)
Definition chaingen.h:706
handles core cryptonote functionality
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_replay_events_get_core()

template<class t_test_class>
bool do_replay_events_get_core ( std::vector< test_event_entry > & events,
cryptonote::core * core )
inline

Definition at line 706 of file chaingen.h.

707{
708 boost::program_options::options_description desc("Allowed options");
710 boost::program_options::variables_map vm;
711 bool r = command_line::handle_error_helper(desc, [&]()
712 {
713 boost::program_options::store(boost::program_options::basic_parsed_options<char>(&desc), vm);
714 boost::program_options::notify(vm);
715 return true;
716 });
717 if (!r)
718 return false;
719
720 auto & c = *core;
721
722 // FIXME: make sure that vm has arg_testnet_on set to true or false if
723 // this test needs for it to be so.
725
726 // Hardforks can be specified in events.
727 v_hardforks_t hardforks;
728 cryptonote::test_options test_options_tmp{nullptr, 0};
729 const cryptonote::test_options * test_options_ = &gto.test_options;
730 if (extract_hard_forks(events, hardforks)){
731 hardforks.push_back(std::make_pair((uint8_t)0, (uint64_t)0)); // terminator
732 test_options_tmp.hard_forks = hardforks.data();
733 test_options_ = &test_options_tmp;
734 }
735
736 if (!c.init(vm, test_options_))
737 {
738 MERROR("Failed to init core");
739 return false;
740 }
741 c.get_blockchain_storage().get_db().set_batch_transactions(true);
742
743 // start with a clean pool
744 std::vector<crypto::hash> pool_txs;
745 if (!c.get_pool_transaction_hashes(pool_txs))
746 {
747 MERROR("Failed to flush txpool");
748 return false;
749 }
750 c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
751
752 t_test_class validator;
753 bool ret = replay_events_through_core<t_test_class>(c, events, validator);
754// c.deinit();
755 return ret;
756}
std::vector< std::pair< uint8_t, uint64_t > > v_hardforks_t
Definition chaingen.h:137
bool extract_hard_forks(const std::vector< test_event_entry > &events, v_hardforks_t &hard_forks)
Definition chaingen.cpp:966
bool replay_events_through_core(cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator)
Definition chaingen.h:666
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
#define MERROR(x)
Definition misc_log_ex.h:73
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
const std::pair< uint8_t, uint64_t > * hard_forks
const cryptonote::test_options test_options
Definition chaingen.h:699
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_replay_file()

template<class t_test_class>
bool do_replay_file ( const std::string & filename)
inline

Definition at line 783 of file chaingen.h.

784{
785 std::vector<test_event_entry> events;
786 if (!tools::unserialize_obj_from_file(events, filename))
787 {
788 MERROR("Failed to deserialize data from file: ");
789 return false;
790 }
791 return do_replay_events<t_test_class>(events);
792}
bool unserialize_obj_from_file(t_object &obj, const std::string &file_path)
Here is the call graph for this function:

◆ dump_data()

std::string dump_data ( const cryptonote::transaction & tx)

Definition at line 617 of file chaingen.cpp.

618{
619 ostringstream ss;
620 ss << "msg: " << dump_keys(tx.rct_signatures.message.bytes)
621 << ", vin: ";
622
623 for(auto & in : tx.vin){
624 if (typeid(txin_to_key) == in.type()){
625 auto tk = boost::get<txin_to_key>(in);
626 std::vector<uint64_t> full_off;
627 int64_t last = -1;
628
629 ss << " i: " << tk.amount << " [";
630 for(auto ix : tk.key_offsets){
631 ss << ix << ", ";
632 if (last == -1){
633 last = ix;
634 full_off.push_back(ix);
635 } else {
636 last += ix;
637 full_off.push_back((uint64_t)last);
638 }
639 }
640
641 ss << "], full: [";
642 for(auto ix : full_off){
643 ss << ix << ", ";
644 }
645 ss << "]; ";
646
647 } else if (typeid(txin_gen) == in.type()){
648 ss << " h: " << boost::get<txin_gen>(in).height << ", ";
649 } else {
650 ss << " ?, ";
651 }
652 }
653
654 ss << ", mixring: \n";
655 for (const auto & row : tx.rct_signatures.mixRing){
656 for(auto cur : row){
657 ss << " (" << dump_keys(cur.dest.bytes) << ", " << dump_keys(cur.mask.bytes) << ")\n ";
658 }
659 ss << "; ";
660 }
661
662 return ss.str();
663}
std::string dump_keys(T *buff32)
Definition chaingen.h:271
signed __int64 int64_t
Definition stdint.h:135
unsigned char bytes[32]
Definition rctTypes.h:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_keys()

template<typename T>
std::string dump_keys ( T * buff32)

Definition at line 271 of file chaingen.h.

272{
273 std::ostringstream ss;
274 char buff[10];
275
276 ss << "[";
277 for(int i = 0; i < 32; i++)
278 {
279 snprintf(buff, 10, "0x%02x", ((uint8_t)buff32[i] & 0xff));
280 ss << buff;
281 if (i < 31)
282 ss << ",";
283 }
284 ss << "]";
285 return ss.str();
286}
Here is the caller graph for this function:

◆ extract_hard_forks()

bool extract_hard_forks ( const std::vector< test_event_entry > & events,
v_hardforks_t & hard_forks )

Definition at line 966 of file chaingen.cpp.

967{
968 for(auto & ev : events)
969 {
970 if (typeid(event_replay_settings) == ev.type())
971 {
972 const auto & rep_settings = boost::get<event_replay_settings>(ev);
973 if (rep_settings.hard_forks)
974 {
975 const auto & hf = rep_settings.hard_forks.get();
976 std::copy(hf.begin(), hf.end(), std::back_inserter(hard_forks));
977 }
978 }
979 }
980
981 return !hard_forks.empty();
982}
Here is the caller graph for this function:

◆ fill_nonce()

void fill_nonce ( cryptonote::block & blk,
const cryptonote::difficulty_type & diffic,
uint64_t height )

Definition at line 797 of file chaingen.cpp.

798{
799 blk.nonce = 0;
800 while (!miner::find_nonce_for_given_block(blk, diffic, height))
801 blk.timestamp++;
802}
static bool find_nonce_for_given_block(block &bl, const difficulty_type &diffic, uint64_t height)
Definition miner.cpp:478
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_tx_destinations() [1/3]

void fill_tx_destinations ( const var_addr_t & from,
const cryptonote::account_public_address & to,
uint64_t amount,
uint64_t fee,
const std::vector< cryptonote::tx_source_entry > & sources,
std::vector< cryptonote::tx_destination_entry > & destinations,
bool always_change = false )

◆ fill_tx_destinations() [2/3]

void fill_tx_destinations ( const var_addr_t & from,
const cryptonote::account_public_address & to,
uint64_t amount,
uint64_t fee,
const std::vector< cryptonote::tx_source_entry > & sources,
std::vector< cryptonote::tx_destination_entry > & destinations,
std::vector< cryptonote::tx_destination_entry > & destinations_pure,
bool always_change = false )

◆ fill_tx_destinations() [3/3]

void fill_tx_destinations ( const var_addr_t & from,
const std::vector< cryptonote::tx_destination_entry > & dests,
uint64_t fee,
const std::vector< cryptonote::tx_source_entry > & sources,
std::vector< cryptonote::tx_destination_entry > & destinations,
bool always_change )

◆ fill_tx_sources_and_destinations() [1/2]

void fill_tx_sources_and_destinations ( const std::vector< test_event_entry > & events,
const cryptonote::block & blk_head,
const cryptonote::account_base & from,
const cryptonote::account_base & to,
uint64_t amount,
uint64_t fee,
size_t nmix,
std::vector< cryptonote::tx_source_entry > & sources,
std::vector< cryptonote::tx_destination_entry > & destinations )

Definition at line 789 of file chaingen.cpp.

793{
794 fill_tx_sources_and_destinations(events, blk_head, from, to.get_keys().m_account_address, amount, fee, nmix, sources, destinations);
795}
void fill_tx_sources_and_destinations(const std::vector< test_event_entry > &events, const block &blk_head, const cryptonote::account_base &from, const cryptonote::account_public_address &to, uint64_t amount, uint64_t fee, size_t nmix, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations)
Definition chaingen.cpp:775
const account_keys & get_keys() const
Definition account.cpp:264
account_public_address m_account_address
Definition account.h:43
Here is the call graph for this function:

◆ fill_tx_sources_and_destinations() [2/2]

void fill_tx_sources_and_destinations ( const std::vector< test_event_entry > & events,
const cryptonote::block & blk_head,
const cryptonote::account_base & from,
const cryptonote::account_public_address & to,
uint64_t amount,
uint64_t fee,
size_t nmix,
std::vector< cryptonote::tx_source_entry > & sources,
std::vector< cryptonote::tx_destination_entry > & destinations )

Definition at line 775 of file chaingen.cpp.

779{
780 sources.clear();
781 destinations.clear();
782
783 if (!fill_tx_sources(sources, events, blk_head, from, amount + fee, nmix))
784 throw std::runtime_error("couldn't fill transaction sources");
785
786 fill_tx_destinations(from, to, amount, fee, sources, destinations, false);
787}
bool fill_tx_sources(std::vector< tx_source_entry > &sources, const std::vector< test_event_entry > &events, const block &blk_head, const cryptonote::account_base &from, uint64_t amount, size_t nmix)
Definition chaingen.cpp:396
void fill_tx_destinations(const var_addr_t &from, const std::vector< tx_destination_entry > &dests, uint64_t fee, const std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, bool always_change)
Definition chaingen.cpp:720
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_block_chain() [1/2]

bool find_block_chain ( const std::vector< test_event_entry > & events,
std::vector< const cryptonote::block * > & blockchain,
map_hash2tx_t & mtx,
const crypto::hash & head )

Definition at line 1105 of file chaingen.cpp.

1105 {
1106 std::unordered_map<crypto::hash, const block*> block_index;
1107 BOOST_FOREACH(const test_event_entry& ev, events)
1108 {
1109 if (typeid(block) == ev.type())
1110 {
1111 const block* blk = &boost::get<block>(ev);
1112 block_index[get_block_hash(*blk)] = blk;
1113 }
1114 else if (typeid(transaction) == ev.type())
1115 {
1116 const transaction& tx = boost::get<transaction>(ev);
1117 mtx[get_transaction_hash(tx)] = &tx;
1118 }
1119 }
1120
1121 bool b_success = false;
1122 crypto::hash id = head;
1123 for (auto it = block_index.find(id); block_index.end() != it; it = block_index.find(id))
1124 {
1125 blockchain.push_back(it->second);
1126 id = it->second->prev_id;
1127 if (null_hash == id)
1128 {
1129 b_success = true;
1130 break;
1131 }
1132 }
1133 reverse(blockchain.begin(), blockchain.end());
1134 return b_success;
1135}
boost::variant< cryptonote::block, cryptonote::transaction, std::vector< cryptonote::transaction >, cryptonote::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_replay_settings > test_event_entry
Definition chaingen.h:162
POD_CLASS hash
Definition hash.h:50
bool get_block_hash(const block &b, crypto::hash &res)
crypto::hash get_transaction_hash(const transaction &t)
struct rule_list head
Here is the call graph for this function:

◆ find_block_chain() [2/2]

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 at line 1072 of file chaingen.cpp.

1072 {
1073 std::unordered_map<crypto::hash, const block*> block_index;
1074 BOOST_FOREACH(const test_event_entry& ev, events)
1075 {
1076 if (typeid(block) == ev.type())
1077 {
1078 const block* blk = &boost::get<block>(ev);
1079 block_index[get_block_hash(*blk)] = blk;
1080 }
1081 else if (typeid(transaction) == ev.type())
1082 {
1083 const transaction& tx = boost::get<transaction>(ev);
1084 mtx[get_transaction_hash(tx)] = &tx;
1085 }
1086 }
1087
1088 bool b_success = false;
1089 crypto::hash id = head;
1090 for (auto it = block_index.find(id); block_index.end() != it; it = block_index.find(id))
1091 {
1092 blockchain.push_back(*it->second);
1093 id = it->second->prev_id;
1094 if (null_hash == id)
1095 {
1096 b_success = true;
1097 break;
1098 }
1099 }
1100 reverse(blockchain.begin(), blockchain.end());
1101
1102 return b_success;
1103}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_address() [1/5]

Definition at line 690 of file chaingen.cpp.

691{
692 return inp.get_keys().m_account_address;
693}
const char * inp

◆ get_address() [2/5]

Definition at line 685 of file chaingen.cpp.

686{
687 return inp.m_account_address;
688}

◆ get_address() [3/5]

Definition at line 680 of file chaingen.cpp.

681{
682 return inp;
683}

◆ get_address() [4/5]

Definition at line 695 of file chaingen.cpp.

696{
697 return inp.addr;
698}

◆ get_address() [5/5]

cryptonote::account_public_address get_address ( const var_addr_t & inp)

Definition at line 665 of file chaingen.cpp.

666{
667 if (typeid(cryptonote::account_public_address) == inp.type()){
668 return boost::get<cryptonote::account_public_address>(inp);
669 } else if(typeid(cryptonote::account_keys) == inp.type()){
670 return boost::get<cryptonote::account_keys>(inp).m_account_address;
671 } else if (typeid(cryptonote::account_base) == inp.type()){
672 return boost::get<cryptonote::account_base>(inp).get_keys().m_account_address;
673 } else if (typeid(cryptonote::tx_destination_entry) == inp.type()){
674 return boost::get<cryptonote::tx_destination_entry>(inp).addr;
675 } else {
676 throw std::runtime_error("Unexpected type");
677 }
678}
Here is the caller graph for this function:

◆ get_balance()

uint64_t get_balance ( const cryptonote::account_base & addr,
const std::vector< cryptonote::block > & blockchain,
const map_hash2tx_t & mtx )

Definition at line 940 of file chaingen.cpp.

940 {
941 uint64_t res = 0;
942 std::map<uint64_t, std::vector<output_index> > outs;
943 std::map<uint64_t, std::vector<size_t> > outs_mine;
944
945 map_hash2tx_t confirmed_txs;
946 get_confirmed_txs(blockchain, mtx, confirmed_txs);
947
948 if (!init_output_indices(outs, outs_mine, blockchain, confirmed_txs, addr))
949 return false;
950
951 if (!init_spent_output_indices(outs, outs_mine, blockchain, confirmed_txs, addr))
952 return false;
953
954 BOOST_FOREACH (const map_output_t::value_type &o, outs_mine) {
955 for (size_t i = 0; i < o.second.size(); ++i) {
956 if (outs[o.first][o.second[i]].spent)
957 continue;
958
959 res += outs[o.first][o.second[i]].amount;
960 }
961 }
962
963 return res;
964}
bool init_spent_output_indices(map_output_idx_t &outs, map_output_t &outs_mine, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, const cryptonote::account_base &from)
Definition chaingen.cpp:327
bool init_output_indices(map_output_idx_t &outs, std::map< uint64_t, std::vector< size_t > > &outs_mine, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, const cryptonote::account_base &from)
Definition chaingen.cpp:284
void get_confirmed_txs(const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, map_hash2tx_t &confirmed_txs)
Definition chaingen.cpp:984
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition chaingen.h:163
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_confirmed_txs()

void get_confirmed_txs ( const std::vector< cryptonote::block > & blockchain,
const map_hash2tx_t & mtx,
map_hash2tx_t & confirmed_txs )

Definition at line 984 of file chaingen.cpp.

985{
986 std::unordered_set<crypto::hash> confirmed_hashes;
987 BOOST_FOREACH(const block& blk, blockchain)
988 {
989 BOOST_FOREACH(const crypto::hash& tx_hash, blk.tx_hashes)
990 {
991 confirmed_hashes.insert(tx_hash);
992 }
993 }
994
995 BOOST_FOREACH(const auto& tx_pair, mtx)
996 {
997 if (0 != confirmed_hashes.count(tx_pair.first))
998 {
999 confirmed_txs.insert(tx_pair);
1000 }
1001 }
1002}
std::vector< crypto::hash > tx_hashes
Here is the caller graph for this function:

◆ get_head_block()

cryptonote::block get_head_block ( const std::vector< test_event_entry > & events)

Definition at line 1058 of file chaingen.cpp.

1059{
1060 for(auto it = events.rbegin(); it != events.rend(); ++it)
1061 {
1062 auto &ev = *it;
1063 if (typeid(block) == ev.type())
1064 {
1065 return boost::get<block>(ev);
1066 }
1067 }
1068
1069 throw std::runtime_error("No block event");
1070}
Here is the caller graph for this function:

◆ get_test_difficulty()

cryptonote::difficulty_type get_test_difficulty ( const boost::optional< uint8_t > & hf_ver = boost::none)
inline

Definition at line 409 of file chaingen.h.

409{return !hf_ver || hf_ver.get() <= 1 ? 1 : 2;}
Here is the caller graph for this function:

◆ num_blocks()

uint64_t num_blocks ( const std::vector< test_event_entry > & events)

Definition at line 1044 of file chaingen.cpp.

1045{
1046 uint64_t res = 0;
1047 BOOST_FOREACH(const test_event_entry& ev, events)
1048 {
1049 if (typeid(block) == ev.type())
1050 {
1051 res += 1;
1052 }
1053 }
1054
1055 return res;
1056}
Here is the caller graph for this function:

◆ replay_events_through_core()

template<class t_test_class>
bool replay_events_through_core ( cryptonote::core & cr,
const std::vector< test_event_entry > & events,
t_test_class & validator )
inline

Definition at line 666 of file chaingen.h.

667{
668 return replay_events_through_core_plain(cr, events, validator, true);
669}
bool replay_events_through_core_plain(cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator, bool reinit=true)
Definition chaingen.h:672
Here is the call graph for this function:
Here is the caller graph for this function:

◆ replay_events_through_core_plain()

template<class t_test_class>
bool replay_events_through_core_plain ( cryptonote::core & cr,
const std::vector< test_event_entry > & events,
t_test_class & validator,
bool reinit = true )
inline

Definition at line 672 of file chaingen.h.

673{
674 TRY_ENTRY();
675
676 //init core here
677 if (reinit) {
678 CHECK_AND_ASSERT_MES(typeid(cryptonote::block) == events[0].type(), false,
679 "First event must be genesis block creation");
680 cr.set_genesis_block(boost::get<cryptonote::block>(events[0]));
681 }
682
683 bool r = true;
684 push_core_event_visitor<t_test_class> visitor(cr, events, validator);
685 for(size_t i = 1; i < events.size() && r; ++i)
686 {
687 visitor.event_index(i);
688 r = boost::apply_visitor(visitor, events[i]);
689 }
690
691 return r;
692
693 CATCH_ENTRY_L0("replay_events_through_core", false);
694}
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
#define CATCH_ENTRY_L0(lacation, return_val)
#define TRY_ENTRY()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ replay_events_through_core_validate()

template<class t_test_class>
bool replay_events_through_core_validate ( std::vector< test_event_entry > & events,
cryptonote::core & c )
inline

Definition at line 759 of file chaingen.h.

760{
761 std::vector<crypto::hash> pool_txs;
762 if (!c.get_pool_transaction_hashes(pool_txs))
763 {
764 MERROR("Failed to flush txpool");
765 return false;
766 }
768
769 t_test_class validator;
770 return replay_events_through_core_plain<t_test_class>(c, events, validator, false);
771}
bool flush_txes_from_pool(const std::vector< crypto::hash > &txids)
remove transactions from the transaction pool (if present)
bool get_pool_transaction_hashes(std::vector< crypto::hash > &txs, bool include_unrelayed_txes=true) const
get a list of all transactions in the pool
Blockchain & get_blockchain_storage()
gets the Blockchain instance
Here is the call graph for this function:

◆ sum_amount() [1/2]

uint64_t sum_amount ( const std::vector< cryptonote::tx_destination_entry > & destinations)

Definition at line 700 of file chaingen.cpp.

701{
702 uint64_t amount = 0;
703 for(auto & cur : destinations){
704 amount += cur.amount;
705 }
706
707 return amount;
708}
Here is the caller graph for this function:

◆ sum_amount() [2/2]

uint64_t sum_amount ( const std::vector< cryptonote::tx_source_entry > & sources)

Definition at line 710 of file chaingen.cpp.

711{
712 uint64_t amount = 0;
713 for(auto & cur : sources){
714 amount += cur.amount;
715 }
716
717 return amount;
718}

◆ trim_block_chain() [1/2]

bool trim_block_chain ( std::vector< const cryptonote::block * > & blockchain,
const crypto::hash & tail )

Definition at line 1024 of file chaingen.cpp.

1024 {
1025 size_t cut = 0;
1026 bool found = true;
1027
1028 for(size_t i = 0; i < blockchain.size(); ++i){
1029 crypto::hash chash = get_block_hash(*blockchain[i]);
1030 if (chash == tail){
1031 cut = i;
1032 found = true;
1033 break;
1034 }
1035 }
1036
1037 if (found && cut > 0){
1038 blockchain.erase(blockchain.begin(), blockchain.begin() + cut);
1039 }
1040
1041 return found;
1042}
crypto::hash chash
Definition main.cpp:47
Here is the call graph for this function:

◆ trim_block_chain() [2/2]

bool trim_block_chain ( std::vector< cryptonote::block > & blockchain,
const crypto::hash & tail )

Definition at line 1004 of file chaingen.cpp.

1004 {
1005 size_t cut = 0;
1006 bool found = true;
1007
1008 for(size_t i = 0; i < blockchain.size(); ++i){
1009 crypto::hash chash = get_block_hash(blockchain[i]);
1010 if (chash == tail){
1011 cut = i;
1012 found = true;
1013 break;
1014 }
1015 }
1016
1017 if (found && cut > 0){
1018 blockchain.erase(blockchain.begin(), blockchain.begin() + cut);
1019 }
1020
1021 return found;
1022}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VARIANT_TAG() [1/6]

VARIANT_TAG ( binary_archive ,
callback_entry ,
0xcb  )

◆ VARIANT_TAG() [2/6]

VARIANT_TAG ( binary_archive ,
cryptonote::account_base ,
0xcc  )

◆ VARIANT_TAG() [3/6]

VARIANT_TAG ( binary_archive ,
event_replay_settings ,
0xda  )

◆ VARIANT_TAG() [4/6]

VARIANT_TAG ( binary_archive ,
event_visitor_settings ,
0xcf  )

◆ VARIANT_TAG() [5/6]

VARIANT_TAG ( binary_archive ,
serialized_block ,
0xcd  )

◆ VARIANT_TAG() [6/6]

VARIANT_TAG ( binary_archive ,
serialized_transaction ,
0xce  )