Browse Source

Fixed POW test cases.

cn
Jianping Wu 6 years ago
parent
commit
781e53a22b
  1. 1
      src/pow.cpp
  2. 2
      src/pow.h
  3. 8
      src/test/pow_tests.cpp

1
src/pow.cpp

@ -65,7 +65,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead @@ -65,7 +65,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
assert(pindexFirst);
//return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);
return CalculateDigishieldNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);
}

2
src/pow.h

@ -15,7 +15,7 @@ class CBlockIndex; @@ -15,7 +15,7 @@ class CBlockIndex;
class uint256;
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params&);
unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params&);
unsigned int CalculateDigishieldNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params);
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&);

8
src/test/pow_tests.cpp

@ -22,7 +22,7 @@ BOOST_AUTO_TEST_CASE(get_next_work) @@ -22,7 +22,7 @@ BOOST_AUTO_TEST_CASE(get_next_work)
pindexLast.nHeight = 280223;
pindexLast.nTime = 1358378777; // Block #280223
pindexLast.nBits = 0x1c0ac141;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1c093f8d);
BOOST_CHECK_EQUAL(CalculateDigishieldNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1c1021e1);
}
/* Test the constraint on the upper bound for next work */
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit) @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
pindexLast.nHeight = 2015;
pindexLast.nTime = 1318480354; // Block #2015
pindexLast.nBits = 0x1e0ffff0;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1e0fffff);
BOOST_CHECK_EQUAL(CalculateDigishieldNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1e17ffe8);
}
/* Test the constraint on the lower bound for actual time taken */
@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual) @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
pindexLast.nHeight = 578591;
pindexLast.nTime = 1401757934; // Block #578591
pindexLast.nBits = 0x1b075cf1;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1b01d73c);
BOOST_CHECK_EQUAL(CalculateDigishieldNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1b0b0b69);
}
/* Test the constraint on the upper bound for actual time taken */
@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual) @@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
pindexLast.nHeight = 1001951;
pindexLast.nTime = 1464900315; // Block #46367
pindexLast.nBits = 0x1b015318;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1b054c60);
BOOST_CHECK_EQUAL(CalculateDigishieldNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1b01fca4);
}
BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)

Loading…
Cancel
Save