diff options
author | stratospher <44024636+stratospher@users.noreply.github.com> | 2023-11-15 10:38:40 +0530 |
---|---|---|
committer | stratospher <44024636+stratospher@users.noreply.github.com> | 2024-01-23 22:04:55 +0530 |
commit | 8d6c848a48530893ca40be5c1285541b3e7a94f3 (patch) | |
tree | 9623f102edea8d3791757bc8a1ab1dcf4babe1c5 /test | |
parent | 595ad4b16880ae1f23463ca9985381c8eae945d8 (diff) |
[test] Move MAGIC_BYTES to messages.py
This avoids circular dependency happening when importing MAGIC_BYTES.
Before,
p2p.py <--import for EncryptedP2PState-- v2_p2p.py
| ^
| |
└---------import for MAGIC_BYTES----------┘
Now, MAGIC_BYTES are kept separately in messages.py
Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/feature_addrman.py | 3 | ||||
-rwxr-xr-x | test/functional/feature_reindex.py | 2 | ||||
-rwxr-xr-x | test/functional/p2p_v2_transport.py | 3 | ||||
-rwxr-xr-x | test/functional/test_framework/messages.py | 7 | ||||
-rwxr-xr-x | test/functional/test_framework/p2p.py | 8 |
5 files changed, 11 insertions, 12 deletions
diff --git a/test/functional/feature_addrman.py b/test/functional/feature_addrman.py index 9839993115..a7ce864fde 100755 --- a/test/functional/feature_addrman.py +++ b/test/functional/feature_addrman.py @@ -8,9 +8,8 @@ import os import re import struct -from test_framework.messages import ser_uint256, hash256 +from test_framework.messages import ser_uint256, hash256, MAGIC_BYTES from test_framework.netutil import ADDRMAN_NEW_BUCKET_COUNT, ADDRMAN_TRIED_BUCKET_COUNT, ADDRMAN_BUCKET_SIZE -from test_framework.p2p import MAGIC_BYTES from test_framework.test_framework import BitcoinTestFramework from test_framework.test_node import ErrorMatch from test_framework.util import assert_equal diff --git a/test/functional/feature_reindex.py b/test/functional/feature_reindex.py index 83f1c5003c..f0f32a61ab 100755 --- a/test/functional/feature_reindex.py +++ b/test/functional/feature_reindex.py @@ -11,7 +11,7 @@ """ from test_framework.test_framework import BitcoinTestFramework -from test_framework.p2p import MAGIC_BYTES +from test_framework.messages import MAGIC_BYTES from test_framework.util import assert_equal diff --git a/test/functional/p2p_v2_transport.py b/test/functional/p2p_v2_transport.py index 1a3b4a6d0a..09b887f49c 100755 --- a/test/functional/p2p_v2_transport.py +++ b/test/functional/p2p_v2_transport.py @@ -7,8 +7,7 @@ Test v2 transport """ import socket -from test_framework.messages import NODE_P2P_V2 -from test_framework.p2p import MAGIC_BYTES +from test_framework.messages import MAGIC_BYTES, NODE_P2P_V2 from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index d008cb39aa..cc30424653 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -75,6 +75,13 @@ MAX_OP_RETURN_RELAY = 83 DEFAULT_MEMPOOL_EXPIRY_HOURS = 336 # hours +MAGIC_BYTES = { + "mainnet": b"\xf9\xbe\xb4\xd9", # mainnet + "testnet3": b"\x0b\x11\x09\x07", # testnet3 + "regtest": b"\xfa\xbf\xb5\xda", # regtest + "signet": b"\x0a\x03\xcf\x40", # signet +} + def sha256(s): return hashlib.sha256(s).digest() diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index b1ed97b794..eef55b62e4 100755 --- a/test/functional/test_framework/p2p.py +++ b/test/functional/test_framework/p2p.py @@ -72,6 +72,7 @@ from test_framework.messages import ( msg_wtxidrelay, NODE_NETWORK, NODE_WITNESS, + MAGIC_BYTES, sha256, ) from test_framework.util import ( @@ -140,13 +141,6 @@ MESSAGEMAP = { b"wtxidrelay": msg_wtxidrelay, } -MAGIC_BYTES = { - "mainnet": b"\xf9\xbe\xb4\xd9", # mainnet - "testnet3": b"\x0b\x11\x09\x07", # testnet3 - "regtest": b"\xfa\xbf\xb5\xda", # regtest - "signet": b"\x0a\x03\xcf\x40", # signet -} - class P2PConnection(asyncio.Protocol): """A low-level connection object to a node's P2P interface. |