Skip to content

Commit

Permalink
Add tests for special rules for slow blocks on devnet/testnet (dashpa…
Browse files Browse the repository at this point in the history
…y#2176)

* Add tests for special rules for slow blocks on devnet/testnet

* add 20m and 3h
  • Loading branch information
UdjinM6 committed Jul 9, 2018
1 parent b9a83d2 commit 2ba0c77
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/pow_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ BOOST_AUTO_TEST_CASE(get_next_work)
CBlockHeader blockHeader;
blockHeader.nTime = 1408732505; // Block #123457
BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, params), 0x1b1441de); // Block #123457 has 0x1b1441de

// test special rules for slow blocks on devnet/testnet
SoftSetBoolArg("-devnet", true);
SelectParams(CBaseChainParams::DEVNET);
const Consensus::Params& paramsdev = Params().GetConsensus();

// make sure normal rules apply
blockHeader.nTime = 1408732505; // Block #123457
BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, paramsdev), 0x1b1441de); // Block #123457 has 0x1b1441de

// 10x higher target
blockHeader.nTime = 1408733090; // Block #123457 (10m+1sec)
BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, paramsdev), 0x1c00c8f8); // Block #123457 has 0x1c00c8f8
blockHeader.nTime = 1408733689; // Block #123457 (20m)
BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, paramsdev), 0x1c00c8f8); // Block #123457 has 0x1c00c8f8
// lowest diff possible
blockHeader.nTime = 1408739690; // Block #123457 (2h+1sec)
BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, paramsdev), 0x207fffff); // Block #123457 has 0x207fffff
blockHeader.nTime = 1408743289; // Block #123457 (3h)
BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, paramsdev), 0x207fffff); // Block #123457 has 0x207fffff
}

/* Test the constraint on the upper bound for next work */
Expand Down

0 comments on commit 2ba0c77

Please sign in to comment.