6#include <chainparams.h>
13#include <boost/test/unit_test.hpp>
127 blocks[i].nTime = 1269211443 + i * consensus.nPowTargetSpacing;
128 blocks[i].nBits = 0x1c05a3f4;
143 const int64_t height{consensus.DifficultyAdjustmentInterval() + 1};
145 const unsigned int nbits{0x1c05a3f4};
165 unsigned int nBits{~0x00800000U};
225 std::vector<CBlockIndex>
blocks(10000);
226 for (
int i = 0; i < 10000; i++) {
229 blocks[i].nTime = 1269211443 + i *
chainParams->GetConsensus().nPowTargetSpacing;
230 blocks[i].nBits = 0x207fffff;
234 for (
int j = 0;
j < 1000;
j++) {
247 const auto consensus =
chainParams->GetConsensus();
253 BOOST_CHECK_EQUAL(consensus.nPowTargetTimespan % consensus.nPowTargetSpacing, 0);
265 if (!consensus.fPowNoRetargeting) {
267 targ_max /= consensus.nPowTargetTimespan*4;
arith_uint256 UintToArith256(const uint256 &a)
uint256 ArithToUint256(const arith_uint256 &a)
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...
arith_uint256 GetBitsProof(uint32_t bits)
Compute how much work an nBits value corresponds to.
arith_uint256 GetBlockProof(const CBlockIndex &block)
Compute how much work a block index entry corresponds to.
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,...
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...
unsigned int GetNextWorkRequired(const CBlockIndex *pindexLast, const CBlockHeader *pblock, const Consensus::Params ¶ms)
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)
BOOST_CHECK_NE(OneL.ToString(), ArrayToString(ZeroArray, 32))
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.