|
23 | 23 | from test_framework.messages import ( |
24 | 24 | CBlockHeader, |
25 | 25 | from_hex, |
| 26 | + MAGIC_BYTES, |
| 27 | + MAX_MONEY, |
26 | 28 | msg_headers, |
27 | | - tx_from_hex, |
28 | 29 | ser_varint, |
29 | | - MAX_MONEY, |
| 30 | + tx_from_hex, |
30 | 31 | ) |
31 | 32 | from test_framework.p2p import ( |
32 | 33 | P2PInterface, |
@@ -102,15 +103,15 @@ def expected_error(msg): |
102 | 103 | self.log.info(" - snapshot file with mismatching network magic") |
103 | 104 | invalid_magics = [ |
104 | 105 | # 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], |
110 | 111 | ] |
111 | 112 | for [magic, name, real] in invalid_magics: |
112 | 113 | 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:]) |
114 | 115 | if real: |
115 | 116 | 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) |
116 | 117 | else: |
|
0 commit comments