mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-25 14:28:53 +02:00
Merge bitcoin/bitcoin#28830: [refactor] Check CTxMemPool options in ctor
09ef322acc[[refactor]] Check CTxMemPool options in constructor (TheCharlatan) Pull request description: The tests should run the same checks on the mempool options that the init code also applies. The downside to this patch is that the log line may now be printed more than once in the for loop. This was originally noticed here https://github.com/bitcoin/bitcoin/pull/25290#discussion_r900272797. ACKs for top commit: stickies-v: re-ACK09ef322acc. Fixed unreachable assert and updated docstring, and also added an exception for "-maxmempool must be at least " in the `tx_pool` fuzz test, which makes sense when looking at how the mempool options are constructed in `SetMempoolConstraints`. achow101: ACK09ef322accryanofsky: Code review ACK09ef322acc. Just fuzz test error checking fix and updated comment since last review Tree-SHA512: eb3361411c2db70be17f912e3b14d9cb9c60fb0697a1eded952c3b7e8675b7d783780d45c52e091931d1d80fe0f0280cee98dd57a3100def13af20259d9d1b9e
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
#include <test/util/script.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <util/check.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/translation.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
||||
@@ -107,7 +109,7 @@ void MockTime(FuzzedDataProvider& fuzzed_data_provider, const Chainstate& chains
|
||||
SetMockTime(time);
|
||||
}
|
||||
|
||||
CTxMemPool MakeMempool(FuzzedDataProvider& fuzzed_data_provider, const NodeContext& node)
|
||||
std::unique_ptr<CTxMemPool> MakeMempool(FuzzedDataProvider& fuzzed_data_provider, const NodeContext& node)
|
||||
{
|
||||
// Take the default options for tests...
|
||||
CTxMemPool::Options mempool_opts{MemPoolOptionsForTest(node)};
|
||||
@@ -126,8 +128,13 @@ CTxMemPool MakeMempool(FuzzedDataProvider& fuzzed_data_provider, const NodeConte
|
||||
mempool_opts.check_ratio = 1;
|
||||
mempool_opts.require_standard = fuzzed_data_provider.ConsumeBool();
|
||||
|
||||
bilingual_str error;
|
||||
// ...and construct a CTxMemPool from it
|
||||
return CTxMemPool{mempool_opts};
|
||||
auto mempool{std::make_unique<CTxMemPool>(std::move(mempool_opts), error)};
|
||||
// ... ignore the error since it might be beneficial to fuzz even when the
|
||||
// mempool size is unreasonably small
|
||||
Assert(error.empty() || error.original.starts_with("-maxmempool must be at least "));
|
||||
return mempool;
|
||||
}
|
||||
|
||||
FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
||||
@@ -149,8 +156,8 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
||||
auto outpoints_updater = std::make_shared<OutpointsUpdater>(mempool_outpoints);
|
||||
node.validation_signals->RegisterSharedValidationInterface(outpoints_updater);
|
||||
|
||||
CTxMemPool tx_pool_{MakeMempool(fuzzed_data_provider, node)};
|
||||
MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(&tx_pool_);
|
||||
auto tx_pool_{MakeMempool(fuzzed_data_provider, node)};
|
||||
MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(tx_pool_.get());
|
||||
|
||||
chainstate.SetMempool(&tx_pool);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user