Skip to content

Commit 578ea3e

Browse files
committed
test: round difficulty and networkhashps
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
1 parent 4b8ac9e commit 578ea3e

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
@@ -390,14 +390,13 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
390390
assert 'currentblockweight' not in mining_info
391391
assert_equal(mining_info['bits'], nbits_str(REGTEST_N_BITS))
392392
assert_equal(mining_info['target'], target_str(REGTEST_TARGET))
393-
assert_equal(mining_info['difficulty'], Decimal('4.656542373906925E-10'))
394-
assert_equal(mining_info['next'], {
395-
'height': 201,
396-
'target': target_str(REGTEST_TARGET),
397-
'bits': nbits_str(REGTEST_N_BITS),
398-
'difficulty': Decimal('4.656542373906925E-10')
399-
})
400-
assert_equal(mining_info['networkhashps'], Decimal('0.003333333333333334'))
393+
# We don't care about precision, round to avoid mismatch under Valgrind:
394+
assert_equal(round(mining_info['difficulty'], 10), Decimal('0.0000000005'))
395+
assert_equal(mining_info['next']['height'], 201)
396+
assert_equal(mining_info['next']['target'], target_str(REGTEST_TARGET))
397+
assert_equal(mining_info['next']['bits'], nbits_str(REGTEST_N_BITS))
398+
assert_equal(round(mining_info['next']['difficulty'], 10), Decimal('0.0000000005'))
399+
assert_equal(round(mining_info['networkhashps'], 5), Decimal('0.00333'))
401400
assert_equal(mining_info['pooledtx'], 0)
402401

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

0 commit comments

Comments
 (0)