Changeset View
Changeset View
Standalone View
Standalone View
src/bench/duplicate_inputs.cpp
Show All 9 Lines | |||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <pow/pow.h> | #include <pow/pow.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <script/scriptcache.h> | #include <script/scriptcache.h> | ||||
#include <test/util/setup_common.h> | #include <test/util/setup_common.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
static void DuplicateInputs(benchmark::State &state) { | static void DuplicateInputs(benchmark::Bench &bench) { | ||||
TestingSetup test_setup{ | TestingSetup test_setup{ | ||||
CBaseChainParams::REGTEST, | CBaseChainParams::REGTEST, | ||||
/* extra_args */ | /* extra_args */ | ||||
{ | { | ||||
"-nodebuglogfile", | "-nodebuglogfile", | ||||
"-nodebug", | "-nodebug", | ||||
}, | }, | ||||
}; | }; | ||||
Show All 33 Lines | static void DuplicateInputs(benchmark::Bench &bench) { | ||||
} | } | ||||
naughtyTx.vin.emplace_back(naughtyTx.vin.back()); | naughtyTx.vin.emplace_back(naughtyTx.vin.back()); | ||||
block.vtx.push_back(MakeTransactionRef(std::move(coinbaseTx))); | block.vtx.push_back(MakeTransactionRef(std::move(coinbaseTx))); | ||||
block.vtx.push_back(MakeTransactionRef(std::move(naughtyTx))); | block.vtx.push_back(MakeTransactionRef(std::move(naughtyTx))); | ||||
block.hashMerkleRoot = BlockMerkleRoot(block); | block.hashMerkleRoot = BlockMerkleRoot(block); | ||||
while (state.KeepRunning()) { | bench.run([&] { | ||||
BlockValidationState cvstate{}; | BlockValidationState cvstate{}; | ||||
assert(!CheckBlock(block, cvstate, consensusParams, | assert(!CheckBlock(block, cvstate, consensusParams, | ||||
BlockValidationOptions(GetConfig()) | BlockValidationOptions(GetConfig()) | ||||
.withCheckPoW(false) | .withCheckPoW(false) | ||||
.withCheckMerkleRoot(false))); | .withCheckMerkleRoot(false))); | ||||
assert(cvstate.GetRejectReason() == "bad-txns-inputs-duplicate"); | assert(cvstate.GetRejectReason() == "bad-txns-inputs-duplicate"); | ||||
} | }); | ||||
} | } | ||||
BENCHMARK(DuplicateInputs, 10); | BENCHMARK(DuplicateInputs); |