diff options
author | Lee Clagett <code@leeclagett.com> | 2020-03-25 03:02:28 -0400 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2020-03-14 19:17:15 +0000 |
commit | 5de2295f3c215303527f649461bc2ed7113efc7c (patch) | |
tree | 36530e063fb84662f4bac49cf0a330eb7cc36f09 /tests/core_tests/tx_pool.cpp | |
parent | Merge pull request #6388 (diff) | |
download | monero-5de2295f3c215303527f649461bc2ed7113efc7c.tar.xz |
Correct key image check in tx_pool
Diffstat (limited to 'tests/core_tests/tx_pool.cpp')
-rw-r--r-- | tests/core_tests/tx_pool.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/core_tests/tx_pool.cpp b/tests/core_tests/tx_pool.cpp index 537015dca..cc738c4ba 100644 --- a/tests/core_tests/tx_pool.cpp +++ b/tests/core_tests/tx_pool.cpp @@ -125,10 +125,12 @@ txpool_double_spend_base::txpool_double_spend_base() , m_no_relay_hashes() , m_all_hashes() , m_no_new_index(0) + , m_failed_index(0) , m_new_timestamp_index(0) , m_last_tx(crypto::hash{}) { REGISTER_CALLBACK_METHOD(txpool_double_spend_base, mark_no_new); + REGISTER_CALLBACK_METHOD(txpool_double_spend_base, mark_failed); REGISTER_CALLBACK_METHOD(txpool_double_spend_base, mark_timestamp_change); REGISTER_CALLBACK_METHOD(txpool_double_spend_base, timestamp_change_pause); REGISTER_CALLBACK_METHOD(txpool_double_spend_base, check_unchanged); @@ -143,6 +145,12 @@ bool txpool_double_spend_base::mark_no_new(cryptonote::core& /*c*/, size_t ev_in return true; } +bool txpool_double_spend_base::mark_failed(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/) +{ + m_failed_index = ev_index + 1; + return true; +} + bool txpool_double_spend_base::mark_timestamp_change(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/) { m_new_timestamp_index = ev_index + 1; @@ -483,6 +491,8 @@ bool txpool_double_spend_base::check_tx_verification_context(const cryptonote::t m_last_tx = cryptonote::get_transaction_hash(tx); if (m_no_new_index == event_idx) return !tvc.m_verifivation_failed && !tx_added; + else if (m_failed_index == event_idx) + return tvc.m_verifivation_failed;// && !tx_added; else return !tvc.m_verifivation_failed && tx_added; } @@ -559,3 +569,45 @@ bool txpool_double_spend_local::generate(std::vector<test_event_entry>& events) return true; } +bool txpool_double_spend_keyimage::generate(std::vector<test_event_entry>& events) const +{ + INIT_MEMPOOL_TEST(); + + DO_CALLBACK(events, "check_txpool_spent_keys"); + SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_local_relay); + DO_CALLBACK(events, "mark_no_new"); + + const std::size_t tx_index1 = events.size(); + MAKE_TX(events, tx_0, miner_account, bob_account, send_amount, blk_0); + + DO_CALLBACK(events, "increase_all_tx_count"); + DO_CALLBACK(events, "check_txpool_spent_keys"); + DO_CALLBACK(events, "mark_timestamp_change"); + DO_CALLBACK(events, "check_new_hidden"); + DO_CALLBACK(events, "timestamp_change_pause"); + DO_CALLBACK(events, "mark_no_new"); + const std::size_t tx_index2 = events.size(); + events.push_back(tx_0); + DO_CALLBACK(events, "check_txpool_spent_keys"); + DO_CALLBACK(events, "mark_timestamp_change"); + DO_CALLBACK(events, "check_unchanged"); + + // use same key image with different id + cryptonote::transaction tx_1; + { + auto events_copy = events; + events_copy.erase(events_copy.begin() + tx_index1); + events_copy.erase(events_copy.begin() + tx_index2 - 1); + MAKE_TX(events_copy, tx_temp, miner_account, bob_account, send_amount, blk_0); + tx_1 = tx_temp; + } + + // same key image + DO_CALLBACK(events, "timestamp_change_pause"); + DO_CALLBACK(events, "mark_failed"); + events.push_back(tx_1); + DO_CALLBACK(events, "check_unchanged"); + + return true; +} + |