Skip to content

Commit

Permalink
Merge pull request digibyte#23 from SmartArray/tests/pow_tests
Browse files Browse the repository at this point in the history
test: correct pow_tests
  • Loading branch information
gto90 committed Apr 7, 2021
2 parents 7323711 + ae74c4d commit da15583
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/test/pow_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
pindexLast.nHeight = 2015;
pindexLast.nTime = 1233061996; // Block #2015
pindexLast.nBits = 0x1d00ffff;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1d00ffffU);
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1D01B304U);
}

/* Test the constraint on the lower bound for actual time taken */
Expand Down Expand Up @@ -66,12 +66,21 @@ BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
{
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
std::vector<CBlockIndex> blocks(10000);

for (int i = 0; i < 10000; i++) {
blocks[i].pprev = i ? &blocks[i - 1] : nullptr;
blocks[i].nHeight = i;
blocks[i].nVersion = 1;
blocks[i].nTime = 1269211443 + i * chainParams->GetConsensus().nPowTargetSpacing;
blocks[i].nBits = 0x207fffff; /* target 0x7fffff000... */
blocks[i].nChainWork = i ? blocks[i - 1].nChainWork + GetBlockProof(blocks[i - 1]) : arith_uint256(0);

// Create random block hash
const uint256 randomhash = GetRandHash();
uint256* ptr = new uint256();
*ptr = randomhash;

blocks[i].phashBlock = ptr;
}

for (int j = 0; j < 1000; j++) {
Expand Down

0 comments on commit da15583

Please sign in to comment.