From d37f845e4f94d7f18689ad34127c0c6271b65409 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Tue, 27 Nov 2018 16:15:41 -0800 Subject: [PATCH] Fixed POW test cases. --- src/pow.cpp | 1 - src/pow.h | 2 +- src/test/pow_tests.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 71292b803..87544bb7c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -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); } diff --git a/src/pow.h b/src/pow.h index b8cc34926..b15e0bcb6 100644 --- a/src/pow.h +++ b/src/pow.h @@ -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&); diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp index 7fc3d4dd6..241afd96e 100644 --- a/src/test/pow_tests.cpp +++ b/src/test/pow_tests.cpp @@ -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) 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) 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) 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)