diff options
Diffstat (limited to 'src/test/util')
-rw-r--r-- | src/test/util/chainstate.h | 2 | ||||
-rw-r--r-- | src/test/util/random.h | 5 | ||||
-rw-r--r-- | src/test/util/setup_common.cpp | 14 | ||||
-rw-r--r-- | src/test/util/setup_common.h | 2 | ||||
-rw-r--r-- | src/test/util/txmempool.cpp | 6 |
5 files changed, 18 insertions, 11 deletions
diff --git a/src/test/util/chainstate.h b/src/test/util/chainstate.h index ff95e64b7e..03b44fc894 100644 --- a/src/test/util/chainstate.h +++ b/src/test/util/chainstate.h @@ -56,7 +56,7 @@ CreateAndActivateUTXOSnapshot( // FILE* infile{fsbridge::fopen(snapshot_path, "rb")}; AutoFile auto_infile{infile}; - node::SnapshotMetadata metadata; + node::SnapshotMetadata metadata{node.chainman->GetParams().MessageStart()}; auto_infile >> metadata; malleation(auto_infile, metadata); diff --git a/src/test/util/random.h b/src/test/util/random.h index c910bd6a3a..18ab425e48 100644 --- a/src/test/util/random.h +++ b/src/test/util/random.h @@ -14,9 +14,8 @@ /** * This global and the helpers that use it are not thread-safe. * - * If thread-safety is needed, the global could be made thread_local (given - * that thread_local is supported on all architectures we support) or a - * per-thread instance could be used in the multi-threaded test. + * If thread-safety is needed, a per-thread instance could be + * used in the multi-threaded test. */ extern FastRandomContext g_insecure_rand_ctx; diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 38350b33cc..fd07931716 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -2,9 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#if defined(HAVE_CONFIG_H) -#include <config/bitcoin-config.h> -#endif +#include <config/bitcoin-config.h> // IWYU pragma: keep #include <test/util/setup_common.h> @@ -185,6 +183,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto AppInitParameterInteraction(*m_node.args); LogInstance().StartLogging(); m_node.kernel = std::make_unique<kernel::Context>(); + m_node.ecc_context = std::make_unique<ECC_Context>(); SetupEnvironment(); ValidationCacheSizes validation_cache_sizes{}; @@ -202,6 +201,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto BasicTestingSetup::~BasicTestingSetup() { + m_node.ecc_context.reset(); m_node.kernel.reset(); SetMockTime(0s); // Reset mocktime for following tests LogInstance().DisconnectTestLogger(); @@ -276,7 +276,7 @@ void ChainTestingSetup::LoadVerifyActivateChainstate() options.mempool = Assert(m_node.mempool.get()); options.block_tree_db_in_memory = m_block_tree_db_in_memory; options.coins_db_in_memory = m_coins_db_in_memory; - options.reindex = node::fReindex; + options.reindex = chainman.m_blockman.m_reindexing; options.reindex_chainstate = m_args.GetBoolArg("-reindex-chainstate", false); options.prune = chainman.m_blockman.IsPruneMode(); options.check_blocks = m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS); @@ -552,9 +552,9 @@ void TestChain100Setup::MockMempoolMinFee(const CFeeRate& target_feerate) assert(m_node.mempool->size() == 0); // The target feerate cannot be too low... // ...otherwise the transaction's feerate will need to be negative. - assert(target_feerate > m_node.mempool->m_incremental_relay_feerate); + assert(target_feerate > m_node.mempool->m_opts.incremental_relay_feerate); // ...otherwise this is not meaningful. The feerate policy uses the maximum of both feerates. - assert(target_feerate > m_node.mempool->m_min_relay_feerate); + assert(target_feerate > m_node.mempool->m_opts.min_relay_feerate); // Manually create an invalid transaction. Manually set the fee in the CTxMemPoolEntry to // achieve the exact target feerate. @@ -565,7 +565,7 @@ void TestChain100Setup::MockMempoolMinFee(const CFeeRate& target_feerate) LockPoints lp; // The new mempool min feerate is equal to the removed package's feerate + incremental feerate. const auto tx_fee = target_feerate.GetFee(GetVirtualTransactionSize(*tx)) - - m_node.mempool->m_incremental_relay_feerate.GetFee(GetVirtualTransactionSize(*tx)); + m_node.mempool->m_opts.incremental_relay_feerate.GetFee(GetVirtualTransactionSize(*tx)); m_node.mempool->addUnchecked(CTxMemPoolEntry(tx, /*fee=*/tx_fee, /*time=*/0, /*entry_height=*/1, /*entry_sequence=*/0, /*spends_coinbase=*/true, /*sigops_cost=*/1, lp)); diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 8ccf9b571c..dbd66e3585 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -6,6 +6,7 @@ #define BITCOIN_TEST_UTIL_SETUP_COMMON_H #include <common/args.h> // IWYU pragma: export +#include <kernel/context.h> #include <key.h> #include <node/caches.h> #include <node/context.h> // IWYU pragma: export @@ -15,6 +16,7 @@ #include <util/chaintype.h> // IWYU pragma: export #include <util/check.h> #include <util/fs.h> +#include <util/signalinterrupt.h> #include <util/string.h> #include <util/vector.h> diff --git a/src/test/util/txmempool.cpp b/src/test/util/txmempool.cpp index 870cdd0b32..2657104e7d 100644 --- a/src/test/util/txmempool.cpp +++ b/src/test/util/txmempool.cpp @@ -119,9 +119,15 @@ void CheckMempoolV3Invariants(const CTxMemPool& tx_pool) for (const auto& tx_info : tx_pool.infoAll()) { const auto& entry = *Assert(tx_pool.GetEntry(tx_info.tx->GetHash())); if (tx_info.tx->nVersion == 3) { + // Check that special maximum virtual size is respected + Assert(entry.GetTxSize() <= V3_MAX_VSIZE); + // Check that special v3 ancestor/descendant limits and rules are always respected Assert(entry.GetCountWithDescendants() <= V3_DESCENDANT_LIMIT); Assert(entry.GetCountWithAncestors() <= V3_ANCESTOR_LIMIT); + Assert(entry.GetSizeWithDescendants() <= V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE); + Assert(entry.GetSizeWithAncestors() <= V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE); + // If this transaction has at least 1 ancestor, it's a "child" and has restricted weight. if (entry.GetCountWithAncestors() > 1) { Assert(entry.GetTxSize() <= V3_CHILD_MAX_VSIZE); |