diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -549,7 +549,8 @@ // Update nExtraNonce static uint256 hashPrevBlock; if (hashPrevBlock != pblock->hashPrevBlock) { - nExtraNonce = 0; + FastRandomContext rng; + nExtraNonce = rng.rand32(); hashPrevBlock = pblock->hashPrevBlock; } diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -34,6 +34,7 @@ from test_framework.p2p import P2PInterface from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( + assert_approx, assert_equal, assert_greater_than, assert_greater_than_or_equal, @@ -389,7 +390,7 @@ assert_equal(blockinfo['height'], blockheaderinfo['height']) assert_equal(blockinfo['versionHex'], blockheaderinfo['versionHex']) assert_equal(blockinfo['version'], blockheaderinfo['version']) - assert_equal(blockinfo['size'], 181) + assert_approx(blockinfo['size'], 181) assert_equal(blockinfo['merkleroot'], blockheaderinfo['merkleroot']) # Verify transaction data by check the hex values for tx in blockinfo['tx']: diff --git a/test/functional/rpc_dumptxoutset.py b/test/functional/rpc_dumptxoutset.py --- a/test/functional/rpc_dumptxoutset.py +++ b/test/functional/rpc_dumptxoutset.py @@ -7,8 +7,8 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_raises_rpc_error -import hashlib from pathlib import Path +import os class DumptxoutsetTest(BitcoinTestFramework): @@ -32,17 +32,8 @@ assert_equal(out['coins_written'], 100) assert_equal(out['base_height'], 100) assert_equal(out['path'], str(expected_path)) - # Blockhash should be deterministic based on mocked time. - assert_equal( - out['base_hash'], - '65d0aec2439aae14373c153f596fb90a87b643d9bff3e65f250aa8f055e6816b') - - with open(str(expected_path), 'rb') as f: - digest = hashlib.sha256(f.read()).hexdigest() - # UTXO snapshot hash should be deterministic based on mocked time. - assert_equal( - digest, - '05957e146e38153d84e9294999cc24f0dcdb9902c4834b32c79ae8e8985babea') + + assert_equal(os.path.isfile(expected_path), True) # Specifying a path to an existing file will fail. assert_raises_rpc_error(