diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index df2fdc96435..81709001f1d 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -23,10 +23,11 @@ from test_framework.compressor import ( from test_framework.messages import ( CBlockHeader, from_hex, - msg_headers, - tx_from_hex, - ser_varint, + MAGIC_BYTES, MAX_MONEY, + msg_headers, + ser_varint, + tx_from_hex, ) from test_framework.p2p import ( P2PInterface, @@ -102,15 +103,15 @@ class AssumeutxoTest(BitcoinTestFramework): self.log.info(" - snapshot file with mismatching network magic") invalid_magics = [ # magic, name, real - [0xf9beb4d9, "main", True], - [0x0b110907, "test", True], - [0x0a03cf40, "signet", True], - [0x00000000, "", False], - [0xffffffff, "", False], + [MAGIC_BYTES["mainnet"], "main", True], + [MAGIC_BYTES["testnet4"], "testnet4", True], + [MAGIC_BYTES["signet"], "signet", True], + [0x00000000.to_bytes(4, 'big'), "", False], + [0xffffffff.to_bytes(4, 'big'), "", False], ] for [magic, name, real] in invalid_magics: with open(bad_snapshot_path, 'wb') as f: - f.write(valid_snapshot_contents[:7] + magic.to_bytes(4, 'big') + valid_snapshot_contents[11:]) + f.write(valid_snapshot_contents[:7] + magic + valid_snapshot_contents[11:]) if real: assert_raises_rpc_error(parsing_error_code, f"Unable to parse metadata: The network of the snapshot ({name}) does not match the network of this node (regtest).", node.loadtxoutset, bad_snapshot_path) else: diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 1ba48f9a480..c792d480b8d 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -80,6 +80,7 @@ DEFAULT_MEMPOOL_EXPIRY_HOURS = 336 # hours MAGIC_BYTES = { "mainnet": b"\xf9\xbe\xb4\xd9", # mainnet "testnet3": b"\x0b\x11\x09\x07", # testnet3 + "testnet4": b"\x1c\x16\x3f\x28", # testnet4 "regtest": b"\xfa\xbf\xb5\xda", # regtest "signet": b"\x0a\x03\xcf\x40", # signet }