8#include <chainparams.h>
12#include <test/util/setup_common.h>
14#include <boost/test/unit_test.hpp>
16BOOST_FIXTURE_TEST_SUITE(daa_tests, BasicTestingSetup)
21 block.
pprev = pindexPrev;
22 block.
nHeight = pindexPrev->nHeight + 1;
23 block.
nTime = pindexPrev->nTime + nTimeInterval;
33 std::vector<CBlockIndex> blocks(3000);
39 uint32_t initialBits = currentPow.
GetCompact();
43 blocks[0].nHeight = 0;
44 blocks[0].nTime = 1269211443;
45 blocks[0].nBits = initialBits;
53 for (i = 1; i < 2050; i++) {
62 for (
size_t j = 0; j < 10; i++, j++) {
74 blocks[i] =
GetBlockIndex(&blocks[i - 1], 2 * 600 - 6000, nBits);
80 for (
size_t j = 0; j < 20; i++, j++) {
92 for (
size_t j = 0; j < 10; i++, j++) {
94 const uint32_t nextBits =
104 BOOST_CHECK((currentTarget - nextTarget) < (currentTarget >> 10));
113 for (
size_t j = 0; j < 20; i++, j++) {
115 const uint32_t nextBits =
125 BOOST_CHECK((currentTarget - nextTarget) < (currentTarget >> 4));
142 for (
size_t j = 0; j < 93; i++, j++) {
144 const uint32_t nextBits =
155 BOOST_CHECK((nextTarget - currentTarget) < (currentTarget >> 3));
171 for (
size_t j = 0; j < 192; i++, j++) {
173 const uint32_t nextBits =
184 BOOST_CHECK((nextTarget - currentTarget) < (currentTarget >> 3));
194 for (
size_t j = 0; j < 5; i++, j++) {
196 const uint32_t nextBits =
206 for (
size_t j = 0; j < 130; i++, j++) {
208 const uint32_t nextBits =
219 BOOST_CHECK((nextTarget - currentTarget) < (currentTarget >> 3));
226 for (
size_t j = 0; j < 70; i++, j++) {
228 const uint32_t nextBits =
238 BOOST_CHECK((currentTarget - nextTarget) < (currentTarget >> 3));
247BOOST_AUTO_TEST_SUITE_END()
arith_uint256 UintToArith256(const uint256 &a)
arith_uint256 GetBlockProof(const CBlockIndex &block)
std::string ChainTypeToString(ChainType chain)
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
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
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
uint32_t GetNextDAAWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params ¶ms)
Compute the next required proof of work using a weighted average of the estimated hashrate per block.
static CBlockIndex GetBlockIndex(CBlockIndex *pindexPrev, int64_t nTimeInterval, uint32_t nBits)
BOOST_AUTO_TEST_CASE(daa_test)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
Parameters that influence chain consensus.
uint256 powLimit
Proof of work parameters.