Skip to content

Commit 8cfc09f

Browse files
committed
test: cover testnet4 magic in assumeutxo.py
Replace testnet3 and use MAGIC_BYTES constants.
1 parent 4281e36 commit 8cfc09f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

test/functional/feature_assumeutxo.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
from test_framework.messages import (
2424
CBlockHeader,
2525
from_hex,
26+
MAGIC_BYTES,
27+
MAX_MONEY,
2628
msg_headers,
27-
tx_from_hex,
2829
ser_varint,
29-
MAX_MONEY,
30+
tx_from_hex,
3031
)
3132
from test_framework.p2p import (
3233
P2PInterface,
@@ -102,15 +103,15 @@ def expected_error(msg):
102103
self.log.info(" - snapshot file with mismatching network magic")
103104
invalid_magics = [
104105
# magic, name, real
105-
[0xf9beb4d9, "main", True],
106-
[0x0b110907, "test", True],
107-
[0x0a03cf40, "signet", True],
108-
[0x00000000, "", False],
109-
[0xffffffff, "", False],
106+
[MAGIC_BYTES["mainnet"], "main", True],
107+
[MAGIC_BYTES["testnet4"], "testnet4", True],
108+
[MAGIC_BYTES["signet"], "signet", True],
109+
[0x00000000.to_bytes(4, 'big'), "", False],
110+
[0xffffffff.to_bytes(4, 'big'), "", False],
110111
]
111112
for [magic, name, real] in invalid_magics:
112113
with open(bad_snapshot_path, 'wb') as f:
113-
f.write(valid_snapshot_contents[:7] + magic.to_bytes(4, 'big') + valid_snapshot_contents[11:])
114+
f.write(valid_snapshot_contents[:7] + magic + valid_snapshot_contents[11:])
114115
if real:
115116
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)
116117
else:

test/functional/test_framework/messages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
MAGIC_BYTES = {
8181
"mainnet": b"\xf9\xbe\xb4\xd9", # mainnet
8282
"testnet3": b"\x0b\x11\x09\x07", # testnet3
83+
"testnet4": b"\x1c\x16\x3f\x28", # testnet4
8384
"regtest": b"\xfa\xbf\xb5\xda", # regtest
8485
"signet": b"\x0a\x03\xcf\x40", # signet
8586
}

0 commit comments

Comments
 (0)