Skip to content

Commit ed060e0

Browse files
committed
Merge bitcoin/bitcoin#32725: test: round difficulty and networkhashps
578ea3e test: round difficulty and networkhashps (Sjors Provoost) Pull request description: Both are rational numbers. Client software should only use them to display information to humans. Followup calculations should use the underlying values such as target. Therefore it's not necessary to test the handling of these floating point values. Round them down to avoid spurious test failures. Fixes #32515 ACKs for top commit: Prabhat1308: Code Review ACK [`578ea3e`](bitcoin/bitcoin@578ea3e) achow101: ACK 578ea3e w0xlt: Code review ACK bitcoin/bitcoin@578ea3e janb84: ACK 578ea3e Tree-SHA512: 5fc63c73ad236b7cd55c15da0f1d1e6b45e4289d252147a86717bf77d79f897f42c3e38aa514df6a4a8deca10c87a8710b61b454c533ad56b0daf738365f426c
2 parents daf393b + 578ea3e commit ed060e0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

test/functional/mining_basic.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,13 @@ def run_test(self):
379379
assert 'currentblockweight' not in mining_info
380380
assert_equal(mining_info['bits'], nbits_str(REGTEST_N_BITS))
381381
assert_equal(mining_info['target'], target_str(REGTEST_TARGET))
382-
assert_equal(mining_info['difficulty'], Decimal('4.656542373906925E-10'))
383-
assert_equal(mining_info['next'], {
384-
'height': 201,
385-
'target': target_str(REGTEST_TARGET),
386-
'bits': nbits_str(REGTEST_N_BITS),
387-
'difficulty': Decimal('4.656542373906925E-10')
388-
})
389-
assert_equal(mining_info['networkhashps'], Decimal('0.003333333333333334'))
382+
# We don't care about precision, round to avoid mismatch under Valgrind:
383+
assert_equal(round(mining_info['difficulty'], 10), Decimal('0.0000000005'))
384+
assert_equal(mining_info['next']['height'], 201)
385+
assert_equal(mining_info['next']['target'], target_str(REGTEST_TARGET))
386+
assert_equal(mining_info['next']['bits'], nbits_str(REGTEST_N_BITS))
387+
assert_equal(round(mining_info['next']['difficulty'], 10), Decimal('0.0000000005'))
388+
assert_equal(round(mining_info['networkhashps'], 5), Decimal('0.00333'))
390389
assert_equal(mining_info['pooledtx'], 0)
391390

392391
self.log.info("getblocktemplate: Test default witness commitment")

0 commit comments

Comments
 (0)