8#include <chainparams.h>
11#include <test/util/setup_common.h>
13#include <boost/test/unit_test.hpp>
15BOOST_FIXTURE_TEST_SUITE(daa_tests, BasicTestingSetup)
20 block.
pprev = pindexPrev;
21 block.
nHeight = pindexPrev->nHeight + 1;
22 block.
nTime = pindexPrev->nTime + nTimeInterval;
32 std::vector<CBlockIndex> blocks(3000);
38 uint32_t initialBits = currentPow.
GetCompact();
42 blocks[0].nHeight = 0;
43 blocks[0].nTime = 1269211443;
44 blocks[0].nBits = initialBits;
52 for (i = 1; i < 2050; i++) {
61 for (
size_t j = 0; j < 10; i++, j++) {
73 blocks[i] =
GetBlockIndex(&blocks[i - 1], 2 * 600 - 6000, nBits);
79 for (
size_t j = 0; j < 20; i++, j++) {
91 for (
size_t j = 0; j < 10; i++, j++) {
93 const uint32_t nextBits =
103 BOOST_CHECK((currentTarget - nextTarget) < (currentTarget >> 10));
112 for (
size_t j = 0; j < 20; i++, j++) {
114 const uint32_t nextBits =
124 BOOST_CHECK((currentTarget - nextTarget) < (currentTarget >> 4));
141 for (
size_t j = 0; j < 93; i++, j++) {
143 const uint32_t nextBits =
154 BOOST_CHECK((nextTarget - currentTarget) < (currentTarget >> 3));
170 for (
size_t j = 0; j < 192; i++, j++) {
172 const uint32_t nextBits =
183 BOOST_CHECK((nextTarget - currentTarget) < (currentTarget >> 3));
193 for (
size_t j = 0; j < 5; i++, j++) {
195 const uint32_t nextBits =
205 for (
size_t j = 0; j < 130; i++, j++) {
207 const uint32_t nextBits =
218 BOOST_CHECK((nextTarget - currentTarget) < (currentTarget >> 3));
225 for (
size_t j = 0; j < 70; i++, j++) {
227 const uint32_t nextBits =
237 BOOST_CHECK((currentTarget - nextTarget) < (currentTarget >> 3));
246BOOST_AUTO_TEST_SUITE_END()
arith_uint256 UintToArith256(const uint256 &a)
arith_uint256 GetBlockProof(const CBlockIndex &block)
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
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.