38 #include <boost/archive/binary_oarchive.hpp>
39 #include <boost/archive/binary_iarchive.hpp>
40 #include <boost/program_options.hpp>
41 #include <boost/optional.hpp>
42 #include <boost/serialization/vector.hpp>
43 #include <boost/serialization/variant.hpp>
44 #include <boost/serialization/optional.hpp>
45 #include <boost/serialization/unordered_map.hpp>
46 #include <boost/functional/hash.hpp>
60 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY
61 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "tests.core"
75 template<class Archive>
76 void serialize(Archive & ar, const
unsigned int )
100 template<class Archive>
101 void serialize(Archive & ar, const
unsigned int )
129 template<
class Archive>
130 void serialize(Archive & ar,
const unsigned int )
147 template<
class Archive>
148 void serialize(Archive & ar,
const unsigned int )
163 typedef std::unordered_map<crypto::hash, const cryptonote::transaction*>
map_hash2tx_t;
208 template<
class Archive>
209 void serialize(Archive & ar,
const unsigned int )
242 std::vector<size_t>& block_weights,
const std::list<cryptonote::transaction>& tx_list,
243 const boost::optional<uint8_t>& hf_ver = boost::none);
246 const std::list<cryptonote::transaction>& tx_list = std::list<cryptonote::transaction>(),
247 const boost::optional<uint8_t>& hf_ver = boost::none);
253 const std::vector<crypto::hash>& tx_hashes = std::vector<crypto::hash>(),
size_t txs_sizes = 0,
size_t max_outs = 999,
259 std::unordered_map<crypto::hash, block_info> m_blocks_info;
263 template<
class Archive>
264 void serialize(Archive & ar,
const unsigned int )
273 std::ostringstream ss;
277 for(
int i = 0; i < 32; i++)
279 snprintf(buff, 10,
"0x%02x", ((
uint8_t)buff32[i] & 0xff));
328 std::stringstream ss;
330 ss <<
"output_index{blk_height=" <<
blk_height
331 <<
" tx_no=" <<
tx_no
336 <<
" spent=" <<
spent
357 typedef std::unordered_map<crypto::hash, cryptonote::block>
map_block_t;
358 typedef std::unordered_map<output_hasher, output_index, output_hasher_hasher>
map_txid_output_t;
359 typedef std::unordered_map<crypto::public_key, cryptonote::subaddress_index>
subaddresses_t;
362 typedef boost::variant<cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry>
var_addr_t;
382 void process(
const std::vector<const cryptonote::block*>& blockchain,
const map_hash2tx_t& mtx);
393 template<
class Archive>
394 void serialize(Archive & ar,
const unsigned int )
415 std::vector<cryptonote::tx_destination_entry>
build_dsts(std::initializer_list<dest_wrapper_t> inps);
416 uint64_t sum_amount(
const std::vector<cryptonote::tx_destination_entry>& destinations);
432 std::vector<cryptonote::tx_source_entry> &sources,
436 std::vector<cryptonote::tx_source_entry> &sources,
444 std::vector<cryptonote::tx_source_entry>& sources,
445 const std::vector<cryptonote::tx_destination_entry>& destinations,
446 const boost::optional<cryptonote::account_public_address>& change_addr,
462 const std::vector<cryptonote::tx_source_entry> &sources,
463 std::vector<cryptonote::tx_destination_entry>& destinations,
bool always_change=
false);
467 const std::vector<cryptonote::tx_source_entry> &sources,
468 std::vector<cryptonote::tx_destination_entry>& destinations,
473 const std::vector<cryptonote::tx_source_entry> &sources,
474 std::vector<cryptonote::tx_destination_entry>& destinations,
475 std::vector<cryptonote::tx_destination_entry>& destinations_pure,
476 bool always_change=
false);
482 std::vector<cryptonote::tx_source_entry>& sources,
483 std::vector<cryptonote::tx_destination_entry>& destinations);
488 std::vector<cryptonote::tx_source_entry>& sources,
489 std::vector<cryptonote::tx_destination_entry>& destinations);
498 template<
class t_test_
class>
503 const std::vector<test_event_entry>& m_events;
504 t_test_class& m_validator;
507 bool m_txs_keeped_by_block;
513 , m_validator(validator)
515 , m_txs_keeped_by_block(
false)
521 m_ev_index = ev_index;
526 log_event(
"event_replay_settings");
532 log_event(
"event_visitor_settings");
544 log_event(
"cryptonote::transaction");
550 bool r = m_validator.check_tx_verification_context(tvc, tx_added, m_ev_index, tx);
555 bool operator()(
const std::vector<cryptonote::transaction>& txs)
const
557 log_event(
"cryptonote::transaction");
559 std::vector<cryptonote::blobdata> tx_blobs;
560 std::vector<cryptonote::tx_verification_context> tvcs;
562 for (
const auto &tx: txs)
565 tvcs.push_back(tvc0);
570 bool r = m_validator.check_tx_verification_context_array(tvcs, tx_added, m_ev_index, txs);
577 log_event(
"cryptonote::block");
581 std::vector<cryptonote::block> pblocks;
588 bvc.m_verification_failed =
true;
589 bool r = m_validator.check_block_verification_context(bvc, m_ev_index, b);
597 return m_validator.verify(cb.
callback_name, m_c, m_ev_index, m_events);
602 log_event(
"cryptonote::account_base");
608 log_event(
"serialized_block");
611 std::vector<cryptonote::block> pblocks;
618 bvc.m_verification_failed =
true;
621 std::stringstream ss;
629 bool r = m_validator.check_block_verification_context(bvc, m_ev_index, blk);
636 log_event(
"serialized_transaction");
644 std::stringstream ss;
653 bool r = m_validator.check_tx_verification_context(tvc, tx_added, m_ev_index, tx);
659 void log_event(
const std::string& event_type)
const
661 MGINFO_YELLOW(
"=== EVENT # " << m_ev_index <<
": " << event_type);
665 template<
class t_test_
class>
671 template<
class t_test_
class>
679 "First event must be genesis block creation");
685 for(
size_t i = 1; i < events.size() && r; ++i)
688 r = boost::apply_visitor(visitor, events[i]);
696 template<
typename t_test_
class>
705 template<
class t_test_
class>
708 boost::program_options::options_description desc(
"Allowed options");
710 boost::program_options::variables_map vm;
713 boost::program_options::store(boost::program_options::basic_parsed_options<char>(&desc), vm);
714 boost::program_options::notify(vm);
732 test_options_tmp.
hard_forks = hardforks.data();
733 test_options_ = &test_options_tmp;
736 if (!c.init(vm, test_options_))
738 MERROR(
"Failed to init core");
741 c.get_blockchain_storage().get_db().set_batch_transactions(
true);
744 std::vector<crypto::hash> pool_txs;
745 if (!c.get_pool_transaction_hashes(pool_txs))
747 MERROR(
"Failed to flush txpool");
750 c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
752 t_test_class validator;
753 bool ret = replay_events_through_core<t_test_class>(c, events, validator);
758 template<
class t_test_
class>
761 std::vector<crypto::hash> pool_txs;
764 MERROR(
"Failed to flush txpool");
769 t_test_class validator;
770 return replay_events_through_core_plain<t_test_class>(c, events, validator,
false);
773 template<
class t_test_
class>
777 bool ret = do_replay_events_get_core<t_test_class>(events, &core);
782 template<
class t_test_
class>
785 std::vector<test_event_entry> events;
788 MERROR(
"Failed to deserialize data from file: ");
791 return do_replay_events<t_test_class>(events);
795 #define DEFAULT_HARDFORKS(HARDFORKS) do { \
796 HARDFORKS.push_back(std::make_pair((uint8_t)1, (uint64_t)0)); \
799 #define ADD_HARDFORK(HARDFORKS, FORK, HEIGHT) HARDFORKS.push_back(std::make_pair((uint8_t)FORK, (uint64_t)HEIGHT))
801 #define GENERATE_ACCOUNT(account) \
802 cryptonote::account_base account; \
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); \
810 for (size_t msidx = 0; msidx < total; ++msidx) \
811 account[msidx].generate(); \
812 make_multisig_accounts(account, threshold); \
815 #define MAKE_ACCOUNT(VEC_EVENTS, account) \
816 cryptonote::account_base account; \
817 account.generate(); \
818 VEC_EVENTS.push_back(account);
820 #define DO_CALLBACK(VEC_EVENTS, CB_NAME) \
822 callback_entry CALLBACK_ENTRY; \
823 CALLBACK_ENTRY.callback_name = CB_NAME; \
824 VEC_EVENTS.push_back(CALLBACK_ENTRY); \
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));
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));
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);
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);
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);
849 #define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1) \
850 cryptonote::block BLK_NAME; \
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); \
856 VEC_EVENTS.push_back(BLK_NAME);
858 #define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF) \
859 cryptonote::block BLK_NAME; \
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); \
865 VEC_EVENTS.push_back(BLK_NAME);
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);
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);
877 #define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF) \
878 cryptonote::block BLK_NAME; \
880 cryptonote::block blk_last = PREV_BLOCK; \
881 for (size_t i = 0; i < COUNT; ++i) \
883 MAKE_NEXT_BLOCK_HF(VEC_EVENTS, blk, blk_last, MINER_ACC, HF); \
886 BLK_NAME = blk_last; \
889 #define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT) REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, boost::none)
890 #define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC) REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW)
891 #define REWIND_BLOCKS_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF) REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, HF)
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);
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);
903 #define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD) MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, 0, HEAD)
905 #define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
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); \
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)
915 #define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER) \
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); \
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)
925 #define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER) \
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); \
933 #define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD) MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, 0, HEAD)
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);
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);
943 #define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY) \
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)) \
949 #define MAKE_MINER_TX_MANUALLY(TX, BLK) MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, 0)
951 #define SET_EVENT_VISITOR_SETT(VEC_EVENTS, SETT, VAL) VEC_EVENTS.push_back(event_visitor_settings(SETT, VAL));
953 #define GENERATE(filename, genclass) \
955 std::vector<test_event_entry> events; \
957 g.generate(events); \
958 if (!tools::serialize_obj_to_file(events, filename)) \
960 MERROR("Failed to serialize data to file: " << filename); \
961 throw std::runtime_error("Failed to serialize data to file"); \
966 #define PLAY(filename, genclass) \
967 if(!do_replay_file<genclass>(filename)) \
969 MERROR("Failed to pass test : " << #genclass); \
973 #define CATCH_REPLAY(genclass) \
974 catch (const std::exception& ex) \
976 MERROR(#genclass << " generation failed: what=" << ex.what()); \
980 MERROR(#genclass << " generation failed: generic exception"); \
983 #define REPLAY_CORE(genclass) \
984 if (generated && do_replay_events< genclass >(events)) \
986 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
990 MERROR("#TEST# Failed " << #genclass); \
991 failed_tests.push_back(#genclass); \
994 #define REPLAY_WITH_CORE(genclass, CORE) \
995 if (generated && replay_events_through_core_validate< genclass >(events, CORE)) \
997 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
1001 MERROR("#TEST# Failed " << #genclass); \
1002 failed_tests.push_back(#genclass); \
1005 #define CATCH_GENERATE_REPLAY(genclass) \
1006 CATCH_REPLAY(genclass); \
1007 REPLAY_CORE(genclass);
1009 #define CATCH_GENERATE_REPLAY_CORE(genclass, CORE) \
1010 CATCH_REPLAY(genclass); \
1011 REPLAY_WITH_CORE(genclass, CORE);
1013 #define GENERATE_AND_PLAY(genclass) \
1015 std::cout << #genclass << std::endl; \
1016 else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1018 std::vector<test_event_entry> events; \
1020 bool generated = false; \
1024 generated = g.generate(events); \
1026 CATCH_GENERATE_REPLAY(genclass); \
1029 #define GENERATE_AND_PLAY_INSTANCE(genclass, ins, CORE) \
1030 if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1032 std::vector<test_event_entry> events; \
1034 bool generated = false; \
1037 generated = ins.generate(events); \
1039 CATCH_GENERATE_REPLAY_CORE(genclass, CORE); \
1042 #define CALL_TEST(test_name, function) \
1046 MERROR("#TEST# Failed " << test_name); \
1051 MGINFO_GREEN("#TEST# Succeeded " << test_name); \
1055 #define QUOTEME(x) #x
1056 #define DEFINE_TESTS_ERROR_CONTEXT(text) const char* perr_context = text;
1057 #define CHECK_TEST_CONDITION(cond) CHECK_AND_ASSERT_MES(cond, false, "[" << perr_context << "] failed: \"" << QUOTEME(cond) << "\"")
1058 #define CHECK_EQ(v1, v2) CHECK_AND_ASSERT_MES(v1 == v2, false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " == " << QUOTEME(v2) << "\", " << v1 << " != " << v2)
1059 #define CHECK_NOT_EQ(v1, v2) CHECK_AND_ASSERT_MES(!(v1 == v2), false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " != " << QUOTEME(v2) << "\", " << v1 << " == " << v2)
1060 #define MK_COINS(amount) (UINT64_C(amount) * COIN)
1061 #define TESTS_DEFAULT_FEE ((uint64_t)10)
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
cryptonote::block get_head_block(const std::vector< test_event_entry > &events)
bool replay_events_through_core_validate(std::vector< test_event_entry > &events, cryptonote::core &c)
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_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)
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
uint64_t current_difficulty_window(const boost::optional< uint8_t > &hf_ver=boost::none)
serialized_object< cryptonote::block > serialized_block
std::map< uint64_t, std::vector< output_index > > map_output_idx_t
boost::hash< output_hasher > output_hasher_hasher
std::vector< std::pair< uint8_t, uint64_t > > v_hardforks_t
serialized_object< cryptonote::transaction > serialized_transaction
uint64_t sum_amount(const std::vector< cryptonote::tx_destination_entry > &destinations)
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > subaddresses_t
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)
uint64_t num_blocks(const std::vector< test_event_entry > &events)
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 do_replay_events_get_core(std::vector< test_event_entry > &events, cryptonote::core *core)
std::unordered_map< output_hasher, output_index, output_hasher_hasher > map_txid_output_t
bool do_replay_events(std::vector< test_event_entry > &events)
cryptonote::account_public_address get_address(const var_addr_t &inp)
cryptonote::tx_destination_entry build_dst(const var_addr_t &to, bool is_subaddr=false, uint64_t amount=0)
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)
boost::variant< cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry > var_addr_t
std::pair< uint64_t, size_t > outloc_t
bool do_replay_file(const std::string &filename)
std::string dump_keys(T *buff32)
void fill_nonce(cryptonote::block &blk, const cryptonote::difficulty_type &diffic, uint64_t height)
cryptonote::difficulty_type get_test_difficulty(const boost::optional< uint8_t > &hf_ver=boost::none)
bool trim_block_chain(std::vector< cryptonote::block > &blockchain, const crypto::hash &tail)
std::tuple< uint64_t, crypto::public_key, rct::key > get_outs_entry
bool extract_hard_forks(const std::vector< test_event_entry > &events, v_hardforks_t &hard_forks)
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)
std::vector< cryptonote::tx_destination_entry > build_dsts(const var_addr_t &to1, bool sub1=false, uint64_t am1=0)
std::pair< crypto::hash, size_t > output_hasher
std::string dump_data(const cryptonote::transaction &tx)
VARIANT_TAG(binary_archive, callback_entry, 0xcb)
uint64_t get_balance(const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
bool replay_events_through_core_plain(cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator, bool reinit=true)
std::map< uint64_t, std::vector< size_t > > map_output_t
void get_confirmed_txs(const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, map_hash2tx_t &confirmed_txs)
std::unordered_map< crypto::hash, cryptonote::block > map_block_t
bool replay_events_through_core(cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator)
block_tracker(const block_tracker &bt)
void process(const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
void global_indices(const cryptonote::transaction *tx, std::vector< uint64_t > &indices)
void get_fake_outs(size_t num_outs, uint64_t amount, uint64_t global_index, uint64_t cur_height, std::vector< get_outs_entry > &outs)
map_txid_output_t m_map_outs
friend class boost::serialization::access
map_txid_output_t::iterator find_out(const crypto::hash &txid, size_t out)
bool flush_txes_from_pool(const std::vector< crypto::hash > &txids)
remove transactions from the transaction pool (if present)
handles core cryptonote functionality
size_t get_pool_transactions_count() const
get the total number of transactions in the pool
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
bool handle_incoming_txs(const std::vector< blobdata > &tx_blobs, std::vector< tx_verification_context > &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
handles a list of incoming transactions
bool prepare_handle_incoming_blocks(const std::vector< block_complete_entry > &blocks_entry, std::vector< block > &blocks)
performs some preprocessing on a group of incoming blocks to speed up verification
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
Blockchain & get_blockchain_storage()
gets the Blockchain instance
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
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
bool deinit()
performs safe shutdown steps for core and core components
bool handle_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
handles an incoming block
bool handle_incoming_tx(const blobdata &tx_blob, tx_verification_context &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
handles an incoming transaction
rct::rctSig rct_signatures
std::map< std::string, verify_callback > callbacks_map
bool check_tx_verification_context(const cryptonote::tx_verification_context &tvc, bool, size_t, const cryptonote::transaction &)
boost::function< bool(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)> verify_callback
void register_callback(const std::string &cb_name, verify_callback cb)
bool check_block_verification_context(const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
bool check_tx_verification_context_array(const std::vector< cryptonote::tx_verification_context > &tvcs, size_t, size_t, const std::vector< cryptonote::transaction > &)
bool verify(const std::string &cb_name, cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
uint64_t get_already_generated_coins(const crypto::hash &blk_id) const
bool construct_block_manually(cryptonote::block &blk, const cryptonote::block &prev_block, const cryptonote::account_base &miner_acc, int actual_params=bf_none, uint8_t major_ver=0, uint8_t minor_ver=0, uint64_t timestamp=0, const crypto::hash &prev_id=crypto::hash(), const cryptonote::difficulty_type &diffic=1, const cryptonote::transaction &miner_tx=cryptonote::transaction(), const std::vector< crypto::hash > &tx_hashes=std::vector< crypto::hash >(), size_t txs_sizes=0, size_t max_outs=999, uint8_t hf_version=1)
void get_last_n_block_weights(std::vector< size_t > &block_weights, const crypto::hash &head, size_t n) const
test_generator(const test_generator &other)
void get_block_chain(std::vector< block_info > &blockchain, const crypto::hash &head, size_t n) const
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)
void add_block(const cryptonote::block &blk, size_t tsx_size, std::vector< size_t > &block_weights, uint64_t already_generated_coins, uint8_t hf_version=1)
bool construct_block_manually_tx(cryptonote::block &blk, const cryptonote::block &prev_block, const cryptonote::account_base &miner_acc, const std::vector< crypto::hash > &tx_hashes, size_t txs_size)
friend class boost::serialization::access
#define DIFFICULTY_TARGET
#define DIFFICULTY_TARGET_V6
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
#define CATCH_ENTRY_L0(lacation, return_val)
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
void serialize(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
boost::multiprecision::uint128_t difficulty_type
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key, txout_to_key_public > txout_target_v
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
key commit(etn_amount amount, const key &mask)
void serialize(Archive &a, unsigned_tx_set &x, const boost::serialization::version_type ver)
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL \detailed for described the serialization of an object
#define FIELD(f)
tags the field with the variable name and then serializes it
#define END_SERIALIZE()
self-explanatory
unsigned __int64 uint64_t
std::string callback_name
const std::pair< uint8_t, uint64_t > * hard_forks
boost::optional< v_hardforks_t > hard_forks
friend class boost::serialization::access
event_replay_settings()=default
@ set_txs_keeped_by_block
event_visitor_settings(int a_valid_mask=0, bool a_txs_keeped_by_block=false)
friend class boost::serialization::access
const std::pair< uint8_t, uint64_t > hard_forks[2]
const cryptonote::test_options test_options
const cryptonote::transaction * p_tx
const std::string toString() const
const cryptonote::block * p_blk
output_index(const cryptonote::txout_target_v &_out, uint64_t _a, size_t _h, size_t tno, size_t ono, const cryptonote::block *_pb, const cryptonote::transaction *_pt)
rct::key commitment() const
const cryptonote::txout_target_v out
output_index(const output_index &other)
output_index & operator=(const output_index &other)
bool operator()(const callback_entry &cb) const
push_core_event_visitor(cryptonote::core &c, const std::vector< test_event_entry > &events, t_test_class &validator)
bool operator()(const cryptonote::block &b) const
bool operator()(const cryptonote::transaction &tx) const
bool operator()(const serialized_block &sr_block) const
bool operator()(const cryptonote::account_base &ab) const
bool operator()(const event_replay_settings &settings)
void event_index(size_t ev_index)
bool operator()(const std::vector< cryptonote::transaction > &txs) const
bool operator()(const serialized_transaction &sr_tx) const
bool operator()(const event_visitor_settings &settings)
serialized_object(const cryptonote::blobdata &a_data)
cryptonote::blobdata data
uint64_t already_generated_coins
block_info(crypto::hash a_prev_id, uint64_t an_already_generated_coins, size_t a_block_weight)
friend class boost::serialization::access