6#include <chainparams.h>
12#include <boost/test/unit_test.hpp>
20 int64_t nLastRetargetTime = 1261130161;
23 pindexLast.
nTime = 1262152739;
24 pindexLast.
nBits = 0x1d00ffff;
30 unsigned int expected_nbits = 0x1d00d86aU;
39 int64_t nLastRetargetTime = 1231006505;
42 pindexLast.
nTime = 1233061996;
43 pindexLast.
nBits = 0x1d00ffff;
44 unsigned int expected_nbits = 0x1d00ffffU;
53 int64_t nLastRetargetTime = 1279008237;
56 pindexLast.
nTime = 1279297671;
57 pindexLast.
nBits = 0x1c05a3f4;
58 unsigned int expected_nbits = 0x1c0168fdU;
62 unsigned int invalid_nbits = expected_nbits-1;
70 int64_t nLastRetargetTime = 1263163443;
73 pindexLast.
nTime = 1269211443;
74 pindexLast.
nBits = 0x1c387f6f;
75 unsigned int expected_nbits = 0x1d00e1fdU;
79 unsigned int invalid_nbits = expected_nbits+1;
97 unsigned int nBits{~0x00800000U};
140 std::vector<CBlockIndex> blocks(10000);
141 for (
int i = 0; i < 10000; i++) {
142 blocks[i].pprev = i ? &blocks[i - 1] :
nullptr;
143 blocks[i].nHeight = i;
144 blocks[i].nTime = 1269211443 + i * chainParams->GetConsensus().nPowTargetSpacing;
145 blocks[i].nBits = 0x207fffff;
149 for (
int j = 0; j < 1000; j++) {
162 const auto consensus = chainParams->GetConsensus();
165 BOOST_CHECK_EQUAL(consensus.hashGenesisBlock, chainParams->GenesisBlock().GetHash());
168 BOOST_CHECK_EQUAL(consensus.nPowTargetTimespan % consensus.nPowTargetSpacing, 0);
173 pow_compact.
SetCompact(chainParams->GenesisBlock().nBits, &neg, &over);
179 if (!consensus.fPowNoRetargeting) {
181 targ_max /= consensus.nPowTargetTimespan*4;
arith_uint256 UintToArith256(const uint256 &a)
uint256 ArithToUint256(const arith_uint256 &a)
arith_uint256 GetBlockProof(const CBlockIndex &block)
int64_t GetBlockProofEquivalentTime(const CBlockIndex &to, const CBlockIndex &from, const CBlockIndex &tip, const Consensus::Params ¶ms)
Return the time it would take to redo the work difference between from and to, assuming the current h...
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const ChainType chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
The block chain is a tree shaped structure starting with the genesis block at the root,...
int64_t GetBlockTime() const
int nHeight
height of the entry in the chain. The genesis block has height 0
256-bit unsigned big integer.
arith_uint256 & SetCompact(uint32_t nCompact, bool *pfNegative=nullptr, bool *pfOverflow=nullptr)
The "compact" format is a representation of a whole number N using an unsigned 32bit number similar t...
uint32_t GetCompact(bool fNegative=false) const
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
bool PermittedDifficultyTransition(const Consensus::Params ¶ms, int64_t height, uint32_t old_nbits, uint32_t new_nbits)
Return false if the proof-of-work requirement specified by new_nbits at a given height is not possibl...
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
unsigned int CalculateNextWorkRequired(const CBlockIndex *pindexLast, int64_t nFirstBlockTime, const Consensus::Params ¶ms)
BOOST_AUTO_TEST_CASE(get_next_work)
void sanity_check_chainparams(const ArgsManager &args, ChainType chain_type)