following situations are covered:
- negative target
- overflow target
- target easier then powLimit
- invalid hash (hash > target)
Signed-off-by: soroosh-sdi soroosh.sardari@gmail.com
following situations are covered:
Signed-off-by: soroosh-sdi soroosh.sardari@gmail.com
68 | + nBits = UintToArith256(chainParams->GetConsensus().powLimit).GetCompact(true); 69 | + hash.SetHex("0x1"); 70 | + BOOST_CHECK(!CheckProofOfWork(hash, nBits, chainParams->GetConsensus())); 71 | +} 72 | + 73 | +
nit, remove.
Concept ACK.
Looks like you could also add test for when bnTarget == 0?
106 | +BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_zero_target) 107 | +{ 108 | + const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); 109 | + uint256 hash; 110 | + unsigned int nBits; 111 | + arith_uint256 hash_arith;
arith_uint256 hash_arith{0} and remove line below.
please check it again @promag
ACK 1d65373e5563ae6ea39dac7bfbe62eeed55b1e76, just code review.
nit, I'd prefer the following regardless of surrounding tests:
const auto consensus = CreateChainParams(CBaseChainParams::MAIN)->GetConsensus();
ACK 1d65373, just code review.
nit, I'd prefer the following regardless of surrounding tests:
const auto consensus = CreateChainParams(CBaseChainParams::MAIN)->GetConsensus();
I agree, in next commit I will change as you said; and in another merge request I will change other tests as you suggested.
120 | +} 121 | + 122 | BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test) 123 | { 124 | - const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); 125 | + const auto consenses = CreateChainParams(CBaseChainParams::MAIN)->GetConsensus();;
Please don't change existing tests here, there's no real benefit.
59 | @@ -60,14 +60,73 @@ BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual) 60 | BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1d00e1fdU); 61 | } 62 | 63 | +BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_negative_target) 64 | +{ 65 | + const auto consenses = CreateChainParams(CBaseChainParams::MAIN)->GetConsensus(); 66 | + ;
👀 Also typo in "consenses"
Also typo in "consenses"
That was bad :) pushed another commit.
following situations are covered:
- negative target
- overflow target
- target easier then powLimit
- invalid hash (hash > target)
- zero target
Signed-off-by: soroosh-sdi <soroosh.sardari@gmail.com>
ACK 0cc7dd74e0af735dddf7e786f4ed136c382a4ad5, just read the code.
thanks for adding tests ! :tada: ACK 0cc7dd74e0af735dddf7e786f4ed136c382a4ad5