Adjust test to avoid spurious failures

Previously, if the two random numbers happened to be equal, the block time
would not be updated, and subsequent checks would fail.
This commit is contained in:
Jack Grigg 2016-09-08 11:34:50 +12:00
parent 4a749674a8
commit aea79ec053
1 changed files with 2 additions and 3 deletions

View File

@ -31,9 +31,8 @@ TEST(PoW, DifficultyAveraging) {
// returns, it is. Somehow it ends up off by one....
EXPECT_EQ(0x1e7ffffe, GetNextWorkRequired(&blocks[lastBlk], nullptr, params));
// Randomise the final block time
blocks[lastBlk].nTime += GetRand(params.nPowTargetSpacing)
- GetRand(params.nPowTargetSpacing/2);
// Randomise the final block time (plus 1 to ensure it is always different)
blocks[lastBlk].nTime += GetRand(params.nPowTargetSpacing/2) + 1;
// Result should be the same as if last difficulty was used
EXPECT_EQ(CalculateNextWorkRequired(&blocks[lastBlk],