diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index ebe69442..5318bc33 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -30,6 +30,7 @@ #define CURRENT_TRANSACTION_VERSION 2 #define TRANSACTION_VERSION_INITAL 0 #define TRANSACTION_VERSION_PRE_HF4 1 +#define TRANSACTION_VERSION_POST_HF4 2 #define HF1_BLOCK_MAJOR_VERSION 1 #define HF3_BLOCK_MAJOR_VERSION 2 #define CURRENT_BLOCK_MAJOR_VERSION 3 diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index 7086798f..129198f9 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -1061,14 +1061,8 @@ int main(int argc, char* argv[]) GENERATE_AND_PLAY(zarcanum_basic_test); - //stop_on_first_fail = true; - //for (size_t i = 0; i != 100; i++) - //{ - multiassets_basic_test::ts_starter = 0; - GENERATE_AND_PLAY(multiassets_basic_test); - //} - - + GENERATE_AND_PLAY(multiassets_basic_test); + GENERATE_AND_PLAY(zarcanum_test_n_inputs_validation); // GENERATE_AND_PLAY(gen_block_reward); // END OF TESTS */ diff --git a/tests/core_tests/zarcanum_test.cpp b/tests/core_tests/zarcanum_test.cpp index 7ce373d5..ffad0c0b 100644 --- a/tests/core_tests/zarcanum_test.cpp +++ b/tests/core_tests/zarcanum_test.cpp @@ -8,6 +8,8 @@ #include "wallet_test_core_proxy.h" #include "random_helper.h" +#include "tx_builder.h" + #define AMOUNT_TO_TRANSFER_ZARCANUM_BASIC (TESTS_DEFAULT_FEE*10) @@ -52,6 +54,7 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect account_base alice_acc; alice_acc.generate(); std::shared_ptr alice_wlt = init_playtime_test_wallet(events, c, alice_acc); + //pass over hardfork r = mine_next_pow_blocks_in_playtime(miner_wlt->get_account().get_public_address(), c, 2); @@ -165,3 +168,62 @@ bool zarcanum_basic_test::c1(currency::core& c, size_t ev_index, const std::vect return true; } + + + +zarcanum_test_n_inputs_validation::zarcanum_test_n_inputs_validation() +{ + REGISTER_CALLBACK_METHOD(zarcanum_basic_test, configure_core); + + m_hardforks.set_hardfork_height(1, 1); + m_hardforks.set_hardfork_height(2, 1); + m_hardforks.set_hardfork_height(3, 1); + m_hardforks.set_hardfork_height(4, 12); +} + + +bool zarcanum_test_n_inputs_validation::generate(std::vector& events) const +{ + uint64_t ts_start = 1338224400; + + GENERATE_ACCOUNT(miner_account); + MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start); + REWIND_BLOCKS(events, blk_0r, blk_0, miner_account); + + std::vector sources; + std::vector destinations; + fill_tx_sources_and_destinations(events, blk_0r, miner_account, miner_account, MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations); + destinations.resize(1); + + tx_builder builder; + builder.step1_init(TRANSACTION_VERSION_PRE_HF4); + builder.step2_fill_inputs(miner_account.get_keys(), sources); + builder.step3_fill_outputs(destinations); + builder.step4_calc_hash(); + builder.step5_sign(sources); + +// DO_CALLBACK(events, "mark_invalid_tx"); + events.push_back(builder.m_tx); + + MAKE_NEXT_BLOCK_TX1(events, blk_11, blk_0r, miner_account, builder.m_tx); + REWIND_BLOCKS_N(events, blk_14, blk_11, miner_account, 4); + + + sources.clear(); + destinations.clear(); + fill_tx_sources_and_destinations(events, blk_0r, miner_account, miner_account, MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations); + destinations.resize(1); + tx_builder builder2; + //TODO: implement configuring for zarcanum type outputs + builder2.step1_init(TRANSACTION_VERSION_POST_HF4); + builder2.step2_fill_inputs(miner_account.get_keys(), sources); + builder2.step3_fill_outputs(destinations); + builder2.step4_calc_hash(); + builder2.step5_sign(sources); + + DO_CALLBACK(events, "mark_invalid_tx"); + events.push_back(builder2.m_tx); + REWIND_BLOCKS_N(events, blk_16, blk_14, miner_account, 2); + + return true; +} \ No newline at end of file diff --git a/tests/core_tests/zarcanum_test.h b/tests/core_tests/zarcanum_test.h index a6e2b200..7a40dacf 100644 --- a/tests/core_tests/zarcanum_test.h +++ b/tests/core_tests/zarcanum_test.h @@ -14,3 +14,11 @@ struct zarcanum_basic_test : public wallet_test bool generate(std::vector& events) const; bool c1(currency::core& c, size_t ev_index, const std::vector& events); }; + +struct zarcanum_test_n_inputs_validation : public wallet_test +{ + zarcanum_test_n_inputs_validation(); + bool generate(std::vector& events) const; +}; + +