mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
scripted-diff: test: Use existing chainman in unit tests
-BEGIN VERIFY SCRIPT-
git ls-files -- src/test \
| grep -v '^src/test/fuzz' \
| xargs sed -i -E \
-e 's@g_chainman\.m_blockman@m_node.chainman->m_blockman@g' \
-e 's@([^:])(Chain(state|)Active)@\1::\2@g' \
-e 's@::Chain(state|)Active\(\)@m_node.chainman->ActiveChain\1()@g'
-END VERIFY SCRIPT-
This commit is contained in:
@@ -180,17 +180,17 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
|
||||
m_node.chainman->InitializeChainstate(*m_node.mempool);
|
||||
::ChainstateActive().InitCoinsDB(
|
||||
m_node.chainman->ActiveChainstate().InitCoinsDB(
|
||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
|
||||
assert(!::ChainstateActive().CanFlushToDisk());
|
||||
::ChainstateActive().InitCoinsCache(1 << 23);
|
||||
assert(::ChainstateActive().CanFlushToDisk());
|
||||
if (!::ChainstateActive().LoadGenesisBlock(chainparams)) {
|
||||
assert(!m_node.chainman->ActiveChainstate().CanFlushToDisk());
|
||||
m_node.chainman->ActiveChainstate().InitCoinsCache(1 << 23);
|
||||
assert(m_node.chainman->ActiveChainstate().CanFlushToDisk());
|
||||
if (!m_node.chainman->ActiveChainstate().LoadGenesisBlock(chainparams)) {
|
||||
throw std::runtime_error("LoadGenesisBlock failed.");
|
||||
}
|
||||
|
||||
BlockValidationState state;
|
||||
if (!::ChainstateActive().ActivateBestChain(state, chainparams)) {
|
||||
if (!m_node.chainman->ActiveChainstate().ActivateBestChain(state, chainparams)) {
|
||||
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransa
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
CTxMemPool empty_pool;
|
||||
CBlock block = BlockAssembler(::ChainstateActive(), empty_pool, chainparams).CreateNewBlock(scriptPubKey)->block;
|
||||
CBlock block = BlockAssembler(m_node.chainman->ActiveChainstate(), empty_pool, chainparams).CreateNewBlock(scriptPubKey)->block;
|
||||
|
||||
Assert(block.vtx.size() == 1);
|
||||
for (const CMutableTransaction& tx : txns) {
|
||||
@@ -299,7 +299,7 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
|
||||
// If submit=true, add transaction to the mempool.
|
||||
if (submit) {
|
||||
LOCK(cs_main);
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(::ChainstateActive(), *m_node.mempool.get(), MakeTransactionRef(mempool_txn), /* bypass_limits */ false);
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(m_node.chainman->ActiveChainstate(), *m_node.mempool.get(), MakeTransactionRef(mempool_txn), /* bypass_limits */ false);
|
||||
assert(result.m_result_type == MempoolAcceptResult::ResultType::VALID);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user