From ce4b04014b13a52273a68371d02c3ac300588eb7 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 12 May 2022 18:22:53 +0200 Subject: [PATCH] compilation of core tests fixed --- tests/core_tests/pruning_ring_signatures.cpp | 2 +- tests/core_tests/pruning_ring_signatures.h | 2 +- tests/core_tests/transaction_tests.cpp | 3 ++- tests/core_tests/tx_validation.cpp | 10 +++++----- tests/core_tests/wallet_tests.cpp | 8 ++++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/core_tests/pruning_ring_signatures.cpp b/tests/core_tests/pruning_ring_signatures.cpp index c5ee1469..aedebf6f 100644 --- a/tests/core_tests/pruning_ring_signatures.cpp +++ b/tests/core_tests/pruning_ring_signatures.cpp @@ -41,7 +41,7 @@ struct ev_visitor : public boost::static_visitor }; -bool prun_ring_signatures::generate_blockchain_with_pruned_rs(std::vector& events) +bool prun_ring_signatures::generate_blockchain_with_pruned_rs(std::vector& events)const { uint64_t ts_start = 1338224400; GENERATE_ACCOUNT(miner_account); diff --git a/tests/core_tests/pruning_ring_signatures.h b/tests/core_tests/pruning_ring_signatures.h index 388ec7ea..182413bf 100644 --- a/tests/core_tests/pruning_ring_signatures.h +++ b/tests/core_tests/pruning_ring_signatures.h @@ -17,7 +17,7 @@ public: bool set_check_points(currency::core& c, size_t ev_index, const std::vector& events); bool check_blockchain(currency::core& c, size_t ev_index, const std::vector& events); - bool generate_blockchain_with_pruned_rs(std::vector& events); + bool generate_blockchain_with_pruned_rs(std::vector& events) const; private: }; diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp index 02cd2a3c..7eefd38a 100644 --- a/tests/core_tests/transaction_tests.cpp +++ b/tests/core_tests/transaction_tests.cpp @@ -17,6 +17,7 @@ using namespace currency; bool test_transaction_generation_and_ring_signature() { + currency::hard_forks_descriptor hf = AUTO_VAL_INIT(hf); account_base miner_acc1; miner_acc1.generate(); @@ -98,7 +99,7 @@ bool test_transaction_generation_and_ring_signature() transaction tx_rc1; std::vector attachments; - bool r = construct_tx(miner_acc2.get_keys(), sources, destinations, attachments, tx_rc1, 0); + bool r = construct_tx(miner_acc2.get_keys(), sources, destinations, attachments, tx_rc1, get_tx_version(0, hf), 0); CHECK_AND_ASSERT_MES(r, false, "failed to construct transaction"); crypto::hash pref_hash = get_transaction_prefix_hash(tx_rc1); diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp index 3c7ee250..a57426fd 100644 --- a/tests/core_tests/tx_validation.cpp +++ b/tests/core_tests/tx_validation.cpp @@ -1221,7 +1221,7 @@ bool tx_expiration_time::generate(std::vector& events) const r = fill_tx_sources_and_destinations(events, blk_2, alice_acc.get_keys(), bob_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations); CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed"); transaction tx_2 = AUTO_VAL_INIT(tx_2); - r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_2, 0); + r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_2, get_tx_version_from_events(events), 0); CHECK_AND_ASSERT_MES(r, false, "construct_tx failed"); set_tx_expiration_time(tx_2, ts_median + TX_EXPIRATION_MEDIAN_SHIFT + 1); // one second greather than minimum allowed r = resign_tx(alice_acc.get_keys(), sources, tx_2); @@ -1239,7 +1239,7 @@ bool tx_expiration_time::generate(std::vector& events) const r = fill_tx_sources_and_destinations(events, blk_3, alice_acc.get_keys(), bob_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations); CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed"); transaction tx_3 = AUTO_VAL_INIT(tx_3); - r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3, 0); + r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3, get_tx_version_from_events(events), 0); CHECK_AND_ASSERT_MES(r, false, "construct_tx failed"); set_tx_expiration_time(tx_3, ts_median + TX_EXPIRATION_MEDIAN_SHIFT + 0); // exact expiration time, should not pass (see core condition above) r = resign_tx(alice_acc.get_keys(), sources, tx_3); @@ -1304,7 +1304,7 @@ bool tx_expiration_time_and_block_template::generate(std::vector& events) r = fill_tx_sources_and_destinations(events, blk_0r, m_miner_acc.get_keys(), bob_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations); CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed"); transaction tx_0 = AUTO_VAL_INIT(tx_0); - r = construct_tx(m_miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, 0); + r = construct_tx(m_miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0); CHECK_AND_ASSERT_MES(r, false, "construct_tx failed"); LOG_PRINT_YELLOW("tx_0 = " << get_transaction_hash(tx_0), LOG_LEVEL_0); // do not push tx_0 into events yet diff --git a/tests/core_tests/wallet_tests.cpp b/tests/core_tests/wallet_tests.cpp index e382eaa8..9f3e80f8 100644 --- a/tests/core_tests/wallet_tests.cpp +++ b/tests/core_tests/wallet_tests.cpp @@ -2208,7 +2208,7 @@ bool gen_wallet_offers_size_limit::generate(std::vector& event } // generates such an offer so that result tx will most like have its size within the giving limits -bool generate_oversized_offer(size_t min_size, size_t max_size, bc_services::offer_details_ex& result) +bool generate_oversized_offer(size_t min_size, size_t max_size, bc_services::offer_details_ex& result, uint64_t tx_version) { bc_services::offer_details_ex r = AUTO_VAL_INIT(r); result = r; @@ -2226,7 +2226,7 @@ bool generate_oversized_offer(size_t min_size, size_t max_size, bc_services::off // construct fake tx to estimate it's size transaction tx = AUTO_VAL_INIT(tx); crypto::secret_key one_time_secret_key; - if (!construct_tx(account_keys(), std::vector(), std::vector(), empty_extra, att_container, tx, one_time_secret_key, 0, 0, true, 0)) + if (!construct_tx(account_keys(), std::vector(), std::vector(), empty_extra, att_container, tx, tx_version, one_time_secret_key, 0, 0, true, 0)) return false; size_t sz = get_object_blobsize(tx); @@ -2257,12 +2257,12 @@ bool gen_wallet_offers_size_limit::c1(currency::core& c, size_t ev_index, const CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Incorrect txs count in the pool"); bc_services::offer_details_ex od_normal = AUTO_VAL_INIT(od_normal); - bool r = generate_oversized_offer(CURRENCY_MAX_TRANSACTION_BLOB_SIZE - 2048, CURRENCY_MAX_TRANSACTION_BLOB_SIZE - 1024, od_normal); // generate biggest offer but within tx size limits + bool r = generate_oversized_offer(CURRENCY_MAX_TRANSACTION_BLOB_SIZE - 2048, CURRENCY_MAX_TRANSACTION_BLOB_SIZE - 1024, od_normal, c.get_current_tx_version()); // generate biggest offer but within tx size limits CHECK_AND_ASSERT_MES(r, false, "generate_oversized_offer failed"); od_normal.fee = TESTS_DEFAULT_FEE; bc_services::offer_details_ex od_oversized = AUTO_VAL_INIT(od_oversized); - r = generate_oversized_offer(CURRENCY_MAX_TRANSACTION_BLOB_SIZE, CURRENCY_MAX_TRANSACTION_BLOB_SIZE + 1024, od_oversized); + r = generate_oversized_offer(CURRENCY_MAX_TRANSACTION_BLOB_SIZE, CURRENCY_MAX_TRANSACTION_BLOB_SIZE + 1024, od_oversized, c.get_current_tx_version()); CHECK_AND_ASSERT_MES(r, false, "generate_oversized_offer failed"); od_oversized.fee = TESTS_DEFAULT_FEE;