From aea79ec053509584c26abd1453998d472b8fa0a2 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 8 Sep 2016 11:34:50 +1200 Subject: [PATCH] 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. --- src/gtest/test_pow.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gtest/test_pow.cpp b/src/gtest/test_pow.cpp index 062d2dbd7..998031295 100644 --- a/src/gtest/test_pow.cpp +++ b/src/gtest/test_pow.cpp @@ -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],