aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-12-18 15:56:54 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-11-01 20:56:38 +0000
commitbbe3b276b882af644139d9e35e016eb6ec9298fd (patch)
treefc5f12c79e8da459e5702479eb13dab726159726 /tests
parentMerge pull request #7989 (diff)
downloadmonero-bbe3b276b882af644139d9e35e016eb6ec9298fd.tar.xz
tx_pool: full tx revalidation on fork boundaries
avoids mining txes after a fork that are invalid by this fork's rules, but were valid by the previous fork rules at the time they were verified and added to the txpool.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/long_term_block_weight.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/unit_tests/long_term_block_weight.cpp b/tests/unit_tests/long_term_block_weight.cpp
index f075034bd..c0b057c9a 100644
--- a/tests/unit_tests/long_term_block_weight.cpp
+++ b/tests/unit_tests/long_term_block_weight.cpp
@@ -106,10 +106,16 @@ static uint32_t lcg()
}
+struct BlockchainAndPool
+{
+ cryptonote::tx_memory_pool txpool;
+ cryptonote::Blockchain bc;
+ BlockchainAndPool(): txpool(bc), bc(txpool) {}
+};
+
#define PREFIX_WINDOW(hf_version,window) \
- std::unique_ptr<cryptonote::Blockchain> bc; \
- cryptonote::tx_memory_pool txpool(*bc); \
- bc.reset(new cryptonote::Blockchain(txpool)); \
+ BlockchainAndPool bap; \
+ cryptonote::Blockchain *bc = &bap.bc; \
struct get_test_options { \
const std::pair<uint8_t, uint64_t> hard_forks[3]; \
const cryptonote::test_options test_options = { \
@@ -118,8 +124,7 @@ static uint32_t lcg()
}; \
get_test_options(): hard_forks{std::make_pair(1, (uint64_t)0), std::make_pair((uint8_t)hf_version, (uint64_t)1), std::make_pair((uint8_t)0, (uint64_t)0)} {} \
} opts; \
- cryptonote::Blockchain *blockchain = bc.get(); \
- bool r = blockchain->init(new TestDB(), cryptonote::FAKECHAIN, true, &opts.test_options, 0, NULL); \
+ bool r = bc->init(new TestDB(), cryptonote::FAKECHAIN, true, &opts.test_options, 0, NULL); \
ASSERT_TRUE(r)
#define PREFIX(hf_version) PREFIX_WINDOW(hf_version, TEST_LONG_TERM_BLOCK_WEIGHT_WINDOW)