10#include <boost/test/unit_test.hpp> 
   18    int64_t nLastRetargetTime = 1261130161; 
 
   21    pindexLast.
nTime = 1262152739;  
 
   22    pindexLast.
nBits = 0x1d00ffff;
 
   30    int64_t nLastRetargetTime = 1231006505; 
 
   33    pindexLast.
nTime = 1233061996;  
 
   34    pindexLast.
nBits = 0x1d00ffff;
 
   42    int64_t nLastRetargetTime = 1279008237; 
 
   45    pindexLast.
nTime = 1279297671;  
 
   46    pindexLast.
nBits = 0x1c05a3f4;
 
   54    int64_t nLastRetargetTime = 1263163443; 
 
   57    pindexLast.
nTime = 1269211443;  
 
   58    pindexLast.
nBits = 0x1c387f6f;
 
   76    unsigned int nBits = ~0x00800000;
 
  119    std::vector<CBlockIndex> blocks(10000);
 
  120    for (
int i = 0; i < 10000; i++) {
 
  121        blocks[i].pprev = i ? &blocks[i - 1] : 
nullptr;
 
  122        blocks[i].nHeight = i;
 
  123        blocks[i].nTime = 1269211443 + i * chainParams->GetConsensus().nPowTargetSpacing;
 
  124        blocks[i].nBits = 0x207fffff; 
 
  128    for (
int j = 0; j < 1000; j++) {
 
  141    const auto consensus = chainParams->GetConsensus();
 
  144    BOOST_CHECK_EQUAL(consensus.hashGenesisBlock, chainParams->GenesisBlock().GetHash());
 
  147    BOOST_CHECK_EQUAL(consensus.nPowTargetTimespan % consensus.nPowTargetSpacing, 0);
 
  152    pow_compact.
SetCompact(chainParams->GenesisBlock().nBits, &neg, &over);
 
  158    if (!consensus.fPowNoRetargeting) {
 
  159        arith_uint256 targ_max(
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
 
  160        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 std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
static const std::string REGTEST
static const std::string TESTNET
static const std::string SIGNET
static const std::string MAIN
Chain name strings.
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
void SetHex(const char *psz)
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
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)
void sanity_check_chainparams(const ArgsManager &args, std::string chainName)
BOOST_AUTO_TEST_CASE(get_next_work)
static uint64_t InsecureRandRange(uint64_t range)