mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
test: cover testnet4 magic in assumeutxo.py
Replace testnet3 and use MAGIC_BYTES constants.
This commit is contained in:
parent
4281e3603a
commit
8cfc09fafe
2 changed files with 11 additions and 9 deletions
|
@ -23,10 +23,11 @@ from test_framework.compressor import (
|
||||||
from test_framework.messages import (
|
from test_framework.messages import (
|
||||||
CBlockHeader,
|
CBlockHeader,
|
||||||
from_hex,
|
from_hex,
|
||||||
msg_headers,
|
MAGIC_BYTES,
|
||||||
tx_from_hex,
|
|
||||||
ser_varint,
|
|
||||||
MAX_MONEY,
|
MAX_MONEY,
|
||||||
|
msg_headers,
|
||||||
|
ser_varint,
|
||||||
|
tx_from_hex,
|
||||||
)
|
)
|
||||||
from test_framework.p2p import (
|
from test_framework.p2p import (
|
||||||
P2PInterface,
|
P2PInterface,
|
||||||
|
@ -102,15 +103,15 @@ class AssumeutxoTest(BitcoinTestFramework):
|
||||||
self.log.info(" - snapshot file with mismatching network magic")
|
self.log.info(" - snapshot file with mismatching network magic")
|
||||||
invalid_magics = [
|
invalid_magics = [
|
||||||
# magic, name, real
|
# magic, name, real
|
||||||
[0xf9beb4d9, "main", True],
|
[MAGIC_BYTES["mainnet"], "main", True],
|
||||||
[0x0b110907, "test", True],
|
[MAGIC_BYTES["testnet4"], "testnet4", True],
|
||||||
[0x0a03cf40, "signet", True],
|
[MAGIC_BYTES["signet"], "signet", True],
|
||||||
[0x00000000, "", False],
|
[0x00000000.to_bytes(4, 'big'), "", False],
|
||||||
[0xffffffff, "", False],
|
[0xffffffff.to_bytes(4, 'big'), "", False],
|
||||||
]
|
]
|
||||||
for [magic, name, real] in invalid_magics:
|
for [magic, name, real] in invalid_magics:
|
||||||
with open(bad_snapshot_path, 'wb') as f:
|
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:
|
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)
|
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:
|
else:
|
||||||
|
|
|
@ -80,6 +80,7 @@ DEFAULT_MEMPOOL_EXPIRY_HOURS = 336 # hours
|
||||||
MAGIC_BYTES = {
|
MAGIC_BYTES = {
|
||||||
"mainnet": b"\xf9\xbe\xb4\xd9", # mainnet
|
"mainnet": b"\xf9\xbe\xb4\xd9", # mainnet
|
||||||
"testnet3": b"\x0b\x11\x09\x07", # testnet3
|
"testnet3": b"\x0b\x11\x09\x07", # testnet3
|
||||||
|
"testnet4": b"\x1c\x16\x3f\x28", # testnet4
|
||||||
"regtest": b"\xfa\xbf\xb5\xda", # regtest
|
"regtest": b"\xfa\xbf\xb5\xda", # regtest
|
||||||
"signet": b"\x0a\x03\xcf\x40", # signet
|
"signet": b"\x0a\x03\xcf\x40", # signet
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue