diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-12-26 10:21:21 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-12-26 10:23:17 +0200 |
commit | 95ceb715dc875823f56f930d12a08c349874ce19 (patch) | |
tree | c37d90d5085f3ae0e727490f5ca2700d678898e3 /tests | |
parent | Merge pull request #564 (diff) | |
parent | tests: fix various tests by using parameters better suited to monero (diff) | |
download | monero-95ceb715dc875823f56f930d12a08c349874ce19.tar.xz |
Merge pull request #565
79beed2 tests: fix various tests by using parameters better suited to monero (moneromooo-monero)
d0a8362 tests: fix some double spending tests (moneromooo-monero)
2358d0d tests: use 255 as a "too high" block version (moneromooo-monero)
f33a88c blockchain: fix a few block addition bugs (moneromooo-monero)
a9ff11c blockchain: fix an off by one error in unlocked time check (moneromooo-monero)
f294be3 blockchain: reinstate double spending checks in check_tx_inputs (moneromooo-monero)
737b6d6 blockchain: make some flag twiddling code closer to the original (moneromooo-monero)
81cb0fc blockchain: fix bitflipping test with quantized block rewards (moneromooo-monero)
22ddf09 blockchain: add missing m_tx_pool.on_blockchain_dec (moneromooo-monero)
d837c0c blockchain: fix switch to alternative blockchain for more than one block (moneromooo-monero)
5cec076 blockchain: add a missing validity check to rollback_blockchain_switching (moneromooo-monero)
3cabdb5 core: catch exceptions from get_output_key (moneromooo-monero)
5eef645 db: throw when given a non txout_to_key output to add (moneromooo-monero)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core_tests/block_reward.cpp | 6 | ||||
-rw-r--r-- | tests/core_tests/block_validation.cpp | 9 | ||||
-rw-r--r-- | tests/core_tests/double_spend.h | 15 | ||||
-rw-r--r-- | tests/core_tests/tx_validation.cpp | 8 |
4 files changed, 20 insertions, 18 deletions
diff --git a/tests/core_tests/block_reward.cpp b/tests/core_tests/block_reward.cpp index 789c6fffa..fa06ed71e 100644 --- a/tests/core_tests/block_reward.cpp +++ b/tests/core_tests/block_reward.cpp @@ -80,7 +80,7 @@ namespace generator.get_last_n_block_sizes(block_sizes, get_block_hash(blk_prev), median_block_count); size_t median = misc_utils::median(block_sizes); - median = std::max(median, static_cast<size_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE)); + median = std::max(median, static_cast<size_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1)); transaction miner_tx; bool r = construct_miner_tx_by_size(miner_tx, get_block_height(blk_prev) + 1, generator.get_already_generated_coins(blk_prev), @@ -249,11 +249,11 @@ bool gen_block_reward::check_block_rewards(cryptonote::core& /*c*/, size_t /*ev_ DEFINE_TESTS_ERROR_CONTEXT("gen_block_reward_without_txs::check_block_rewards"); std::array<uint64_t, 7> blk_rewards; - blk_rewards[0] = MONEY_SUPPLY >> 18; + blk_rewards[0] = MONEY_SUPPLY >> EMISSION_SPEED_FACTOR_PER_MINUTE; uint64_t cumulative_reward = blk_rewards[0]; for (size_t i = 1; i < blk_rewards.size(); ++i) { - blk_rewards[i] = (MONEY_SUPPLY - cumulative_reward) >> 18; + blk_rewards[i] = (MONEY_SUPPLY - cumulative_reward) >> EMISSION_SPEED_FACTOR_PER_MINUTE; cumulative_reward += blk_rewards[i]; } diff --git a/tests/core_tests/block_validation.cpp b/tests/core_tests/block_validation.cpp index 440e46647..6a16ee991 100644 --- a/tests/core_tests/block_validation.cpp +++ b/tests/core_tests/block_validation.cpp @@ -79,7 +79,7 @@ bool gen_block_big_major_version::generate(std::vector<test_event_entry>& events BLOCK_VALIDATION_INIT_GENERATE(); block blk_1; - generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_major_ver, CURRENT_BLOCK_MAJOR_VERSION + 1); + generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_major_ver, 255); events.push_back(blk_1); DO_CALLBACK(events, "check_block_purged"); @@ -92,7 +92,7 @@ bool gen_block_big_minor_version::generate(std::vector<test_event_entry>& events BLOCK_VALIDATION_INIT_GENERATE(); block blk_1; - generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_minor_ver, 0, CURRENT_BLOCK_MINOR_VERSION + 1); + generator.construct_block_manually(blk_1, blk_0, miner_account, test_generator::bf_minor_ver, 0, 255); events.push_back(blk_1); DO_CALLBACK(events, "check_block_accepted"); @@ -578,7 +578,7 @@ bool gen_block_invalid_binary_format::generate(std::vector<test_event_entry>& ev while (diffic < 1500); blk_last = boost::get<block>(events.back()); - MAKE_TX(events, tx_0, miner_account, miner_account, MK_COINS(120), boost::get<block>(events[1])); + MAKE_TX(events, tx_0, miner_account, miner_account, MK_COINS(30), boost::get<block>(events[1])); DO_CALLBACK(events, "corrupt_blocks_boundary"); block blk_test; @@ -618,7 +618,8 @@ bool gen_block_invalid_binary_format::check_block_verification_context(const cry } else { - return !bvc.m_added_to_main_chain && (bvc.m_already_exists || bvc.m_marked_as_orphaned || bvc.m_verifivation_failed); + return (!bvc.m_added_to_main_chain && (bvc.m_already_exists || bvc.m_marked_as_orphaned || bvc.m_verifivation_failed)) + || (bvc.m_added_to_main_chain && bvc.m_partial_block_reward); } } diff --git a/tests/core_tests/double_spend.h b/tests/core_tests/double_spend.h index 0a2e60575..467435598 100644 --- a/tests/core_tests/double_spend.h +++ b/tests/core_tests/double_spend.h @@ -32,13 +32,14 @@ #include "chaingen.h" const size_t invalid_index_value = std::numeric_limits<size_t>::max(); +const uint64_t FIRST_BLOCK_REWARD = 17592186044415; template<class concrete_test> class gen_double_spend_base : public test_chain_unit_base { public: - static const uint64_t send_amount = MK_COINS(17); + static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE; gen_double_spend_base(); @@ -60,7 +61,7 @@ private: template<bool txs_keeped_by_block> struct gen_double_spend_in_tx : public gen_double_spend_base< gen_double_spend_in_tx<txs_keeped_by_block> > { - static const uint64_t send_amount = MK_COINS(17); + static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE; static const bool has_invalid_tx = true; static const size_t expected_pool_txs_count = 0; static const uint64_t expected_bob_balance = send_amount; @@ -73,7 +74,7 @@ struct gen_double_spend_in_tx : public gen_double_spend_base< gen_double_spend_i template<bool txs_keeped_by_block> struct gen_double_spend_in_the_same_block : public gen_double_spend_base< gen_double_spend_in_the_same_block<txs_keeped_by_block> > { - static const uint64_t send_amount = MK_COINS(17); + static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE; static const bool has_invalid_tx = !txs_keeped_by_block; static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2; static const uint64_t expected_bob_balance = send_amount; @@ -86,7 +87,7 @@ struct gen_double_spend_in_the_same_block : public gen_double_spend_base< gen_do template<bool txs_keeped_by_block> struct gen_double_spend_in_different_blocks : public gen_double_spend_base< gen_double_spend_in_different_blocks<txs_keeped_by_block> > { - static const uint64_t send_amount = MK_COINS(17); + static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE; static const bool has_invalid_tx = !txs_keeped_by_block; static const size_t expected_pool_txs_count = has_invalid_tx ? 0 : 1; static const uint64_t expected_bob_balance = 0; @@ -99,7 +100,7 @@ struct gen_double_spend_in_different_blocks : public gen_double_spend_base< gen_ template<bool txs_keeped_by_block> struct gen_double_spend_in_alt_chain_in_the_same_block : public gen_double_spend_base< gen_double_spend_in_alt_chain_in_the_same_block<txs_keeped_by_block> > { - static const uint64_t send_amount = MK_COINS(17); + static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE; static const bool has_invalid_tx = !txs_keeped_by_block; static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2; static const uint64_t expected_bob_balance = send_amount; @@ -112,7 +113,7 @@ struct gen_double_spend_in_alt_chain_in_the_same_block : public gen_double_spend template<bool txs_keeped_by_block> struct gen_double_spend_in_alt_chain_in_different_blocks : public gen_double_spend_base< gen_double_spend_in_alt_chain_in_different_blocks<txs_keeped_by_block> > { - static const uint64_t send_amount = MK_COINS(17); + static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE; static const bool has_invalid_tx = !txs_keeped_by_block; static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2; static const uint64_t expected_bob_balance = send_amount; @@ -125,7 +126,7 @@ struct gen_double_spend_in_alt_chain_in_different_blocks : public gen_double_spe class gen_double_spend_in_different_chains : public test_chain_unit_base { public: - static const uint64_t send_amount = MK_COINS(17); + static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE; static const size_t expected_blockchain_height = 4 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW; gen_double_spend_in_different_chains(); diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp index c642f5455..62672c5ca 100644 --- a/tests/core_tests/tx_validation.cpp +++ b/tests/core_tests/tx_validation.cpp @@ -397,17 +397,17 @@ bool gen_tx_key_offest_points_to_foreign_key::generate(std::vector<test_event_en REWIND_BLOCKS(events, blk_1r, blk_1, miner_account); MAKE_ACCOUNT(events, alice_account); MAKE_ACCOUNT(events, bob_account); - MAKE_TX_LIST_START(events, txs_0, miner_account, bob_account, MK_COINS(60) + 1, blk_1); - MAKE_TX_LIST(events, txs_0, miner_account, alice_account, MK_COINS(60) + 1, blk_1); + MAKE_TX_LIST_START(events, txs_0, miner_account, bob_account, MK_COINS(15) + 1, blk_1); + MAKE_TX_LIST(events, txs_0, miner_account, alice_account, MK_COINS(15) + 1, blk_1); MAKE_NEXT_BLOCK_TX_LIST(events, blk_2, blk_1r, miner_account, txs_0); std::vector<tx_source_entry> sources_bob; std::vector<tx_destination_entry> destinations_bob; - fill_tx_sources_and_destinations(events, blk_2, bob_account, miner_account, MK_COINS(60) + 1 - TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, 0, sources_bob, destinations_bob); + fill_tx_sources_and_destinations(events, blk_2, bob_account, miner_account, MK_COINS(15) + 1 - TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, 0, sources_bob, destinations_bob); std::vector<tx_source_entry> sources_alice; std::vector<tx_destination_entry> destinations_alice; - fill_tx_sources_and_destinations(events, blk_2, alice_account, miner_account, MK_COINS(60) + 1 - TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, 0, sources_alice, destinations_alice); + fill_tx_sources_and_destinations(events, blk_2, alice_account, miner_account, MK_COINS(15) + 1 - TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, 0, sources_alice, destinations_alice); tx_builder builder; builder.step1_init(); |