6#include <chainparams.h>
15#include <boost/test/unit_test.hpp>
42 .min_activation_height = 0,
91 for (
unsigned int i = 0; i <
vpblock.size(); i++) {
94 for (
unsigned int i = 0; i <
CHECKERS; i++) {
109 while (
vpblock.size() < height) {
113 pindex->
nTime = nTime;
129 for (
int i = 0; i <
CHECKERS; i++) {
155 for (
int i = 0; i <
CHECKERS; i++) {
163 int height = pindex ==
nullptr ? 0 : pindex->
nHeight + 1;
190 for (
int i = 0; i < 64; i++) {
269 int min_activation_height = params.
vDeployments[dep].min_activation_height;
336 for (
uint32_t i = 1; i < period - 4; i++) {
344 for (
uint32_t i = period - 4; i <= period; i++) {
380 while (
nHeight % period != 0) {
389 for (
uint32_t i = 0; i < period - 1; i++) {
426 if (
lastBlock->nHeight + 1 < min_activation_height) {
478 args.
ForceSetArg(
"-vbparams",
"testdummy:1199145601:1230767999:403200");
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const ChainType chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
ThresholdState GetStateFor(const CBlockIndex *pindexPrev, ThresholdConditionCache &cache) const
Returns the state for pindex A based on parent pindexPrev B.
int GetStateSinceHeightFor(const CBlockIndex *pindexPrev, ThresholdConditionCache &cache) const
Returns the height since when the ThresholdState has started for pindex A based on parent pindexPrev ...
void ForceSetArg(const std::string &strArg, const std::string &strValue)
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
void BuildSkip()
Build the skiplist pointer for this entry.
int32_t nVersion
block header
int nHeight
height of the entry in the chain. The genesis block has height 0
uint64_t randbits(int bits) noexcept
Generate a random (bits)-bit integer.
ThresholdConditionCache cache
~TestConditionChecker() override=default
int StateSinceHeightFor(const CBlockIndex *pindexPrev) const
ThresholdState StateFor(const CBlockIndex *pindexPrev) const
BIP 9 allows multiple softforks to be deployed in parallel.
Class to implement versionbits logic.
VersionBitsTester & TestState(ThresholdState exp, ThresholdState exp_delayed)
VersionBitsTester & TestStateSinceHeight(int height)
VersionBitsTester & TestActive()
VersionBitsTester & TestFailed()
const Deployments test_deployments
std::vector< TestConditionChecker > checker_delayed
VersionBitsTester(FastRandomContext &rng, int32_t nVersionBase=0)
VersionBitsTester & TestLockedIn()
VersionBitsTester & TestState(ThresholdState exp)
FastRandomContext & m_rng
VersionBitsTester & TestDefined()
VersionBitsTester & Mine(unsigned int height, int32_t nTime, int32_t nVersion)
VersionBitsTester & Reset()
std::vector< TestConditionChecker > checker
VersionBitsTester & TestActiveDelayed()
std::vector< TestConditionChecker > checker_never
std::vector< CBlockIndex * > vpblock
std::vector< TestConditionChecker > checker_always
VersionBitsTester & TestStarted()
const int32_t nVersionBase
VersionBitsTester & TestStateSinceHeight(int height, int height_delayed)
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
@ MAX_VERSION_BITS_DEPLOYMENTS
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
void check_computeblockversion(VersionBitsCache &versionbitscache, const Consensus::Params ¶ms, Consensus::DeploymentPos dep)
Check that ComputeBlockVersion will set the appropriate bit correctly Also checks IsActiveAfter() beh...
Struct for each individual consensus rule change using BIP9.
int min_activation_height
If lock in occurs, delay activation until at least this block height.
int bit
Bit position to select the particular bit in nVersion.
static constexpr int64_t ALWAYS_ACTIVE
Special value for nStartTime indicating that the deployment is always active.
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
static constexpr int64_t NO_TIMEOUT
Constant for nTimeout very far in the future.
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Parameters that influence chain consensus.
std::array< BIP9Deployment, MAX_VERSION_BITS_DEPLOYMENTS > vDeployments
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
std::string StateName(ThresholdState state)
Get a string with the state name.
std::map< const CBlockIndex *, ThresholdState > ThresholdConditionCache
static const int32_t VERSIONBITS_TOP_BITS
What bits to set in version for versionbits blocks.
static const int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION
What block version to use for new blocks (pre versionbits)
static const int32_t VERSIONBITS_TOP_MASK
What bitmask determines whether versionbits is in use.
ThresholdState
BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages.
BOOST_FIXTURE_TEST_CASE(versionbits_computeblockversion, BlockVersionTest)
static int32_t TestTime(int nHeight)
BOOST_AUTO_TEST_CASE(versionbits_test)