Changeset View
Changeset View
Standalone View
Standalone View
src/test/miner_tests.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017-2020 The Bitcoin developers | // Copyright (c) 2017-2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <miner.h> | #include <miner.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <consensus/activation.h> | |||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <consensus/merkle.h> | #include <consensus/merkle.h> | ||||
#include <consensus/tx_verify.h> | #include <consensus/tx_verify.h> | ||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
▲ Show 20 Lines • Show All 687 Lines • ▼ Show 20 Lines | BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams, g_mempool) | ||||
.CreateNewBlock(scriptPubKey)); | .CreateNewBlock(scriptPubKey)); | ||||
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5UL); | BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5UL); | ||||
chainActive.Tip()->nHeight--; | chainActive.Tip()->nHeight--; | ||||
SetMockTime(0); | SetMockTime(0); | ||||
g_mempool.clear(); | g_mempool.clear(); | ||||
TestPackageSelection(chainparams, scriptPubKey, txFirst); | TestPackageSelection(chainparams, scriptPubKey, txFirst); | ||||
fCheckpointsEnabled = true; | fCheckpointsEnabled = true; | ||||
int64_t phononActivationTime = | |||||
chainparams.GetConsensus().phononActivationTime; | |||||
// Trick the median time past to activate the phonon upgrade. | |||||
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++) { | |||||
// Trick the MedianTimePast. | |||||
chainActive.Tip()->GetAncestor(chainActive.Tip()->nHeight - i)->nTime = | |||||
phononActivationTime; | |||||
} | |||||
BOOST_CHECK(IsPhononEnabled(chainparams.GetConsensus(), chainActive.Tip())); | |||||
SetMockTime(phononActivationTime + 1); | |||||
AssemblerForTest(chainparams, g_mempool).CreateNewBlock(scriptPubKey); | |||||
} | } | ||||
void CheckBlockMaxSize(const Config &config, uint64_t size, uint64_t expected) { | void CheckBlockMaxSize(const Config &config, uint64_t size, uint64_t expected) { | ||||
gArgs.ForceSetArg("-blockmaxsize", std::to_string(size)); | gArgs.ForceSetArg("-blockmaxsize", std::to_string(size)); | ||||
BlockAssembler ba(config, g_mempool); | BlockAssembler ba(config, g_mempool); | ||||
BOOST_CHECK_EQUAL(ba.GetMaxGeneratedBlockSize(), expected); | BOOST_CHECK_EQUAL(ba.GetMaxGeneratedBlockSize(), expected); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |