Skip to content

Commit 736d2bc

Browse files
MacroFakePastaPastaPasta
authored andcommitted
Merge bitcoin#25126: test: add BIP157 message parsing support (via MESSAGEMAP)
5dc6d92 test: make BIP157 messages default-constructible (MESSAGEMAP compatibility) (Sebastian Falbesoner) 71e4cfe test: p2p: add missing BIP157 message types to MESSAGEMAP (Sebastian Falbesoner) Pull request description: The script [message-capture-parser.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/message-capture/message-capture-parser.py) currently doesn't support parsing the BIP157 messages `getcfilters`, `getcfheaders` and `getcfcheckpt`, e.g. ``` $ ./contrib/message-capture/message-capture-parser.py msgs_recv.dat ... WARNING - Unrecognized message type b'getcfcheckpt' in /home/thestack/bitcoin/msgs_recv.dat ... ``` This PR fixes this by adding the missing message type mappings to the [`MESSAGEMAP`](https://github.com/bitcoin/bitcoin/blob/225e5b57b2ee2bc1acd7f09c89ccccc15ef8c85f/test/functional/test_framework/p2p.py#L95-L127) in the test framework and add default-constructors for the corresponding `msg_`... classes. Without the second commit, the following error message would occur: ``` File "/home/thestack/bitcoin/./contrib/message-capture/message-capture-parser.py", line 141, in process_file msg = MESSAGEMAP[msgtype]() TypeError: __init__() missing 2 required positional arguments: 'filter_type' and 'stop_hash' ``` ACKs for top commit: dunxen: tACK [5dc6d92](bitcoin@5dc6d92) Tree-SHA512: d656c4d38a856373f01d7c293ae7d2b27378a9fc248048ebf2a64725ef8b498b3ddf4f420704abdb20d0c68ca548f1777602c5e73b66821a20c97ae618f1d63f
1 parent b3343d7 commit 736d2bc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

test/functional/test_framework/messages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ class msg_getcfilters:
23712371
__slots__ = ("filter_type", "start_height", "stop_hash")
23722372
msgtype = b"getcfilters"
23732373

2374-
def __init__(self, filter_type, start_height, stop_hash):
2374+
def __init__(self, filter_type=None, start_height=None, stop_hash=None):
23752375
self.filter_type = filter_type
23762376
self.start_height = start_height
23772377
self.stop_hash = stop_hash
@@ -2421,7 +2421,7 @@ class msg_getcfheaders:
24212421
__slots__ = ("filter_type", "start_height", "stop_hash")
24222422
msgtype = b"getcfheaders"
24232423

2424-
def __init__(self, filter_type, start_height, stop_hash):
2424+
def __init__(self, filter_type=None, start_height=None, stop_hash=None):
24252425
self.filter_type = filter_type
24262426
self.start_height = start_height
24272427
self.stop_hash = stop_hash
@@ -2474,7 +2474,7 @@ class msg_getcfcheckpt:
24742474
__slots__ = ("filter_type", "stop_hash")
24752475
msgtype = b"getcfcheckpt"
24762476

2477-
def __init__(self, filter_type, stop_hash):
2477+
def __init__(self, filter_type=None, stop_hash=None):
24782478
self.filter_type = filter_type
24792479
self.stop_hash = stop_hash
24802480

test/functional/test_framework/mininode.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
msg_getaddr,
4545
msg_getblocks,
4646
msg_getblocktxn,
47+
msg_getcfcheckpt,
48+
msg_getcfheaders,
49+
msg_getcfilters,
4750
msg_getdata,
4851
msg_getheaders,
4952
msg_getheaders2,
@@ -93,6 +96,9 @@
9396
b"getaddr": msg_getaddr,
9497
b"getblocks": msg_getblocks,
9598
b"getblocktxn": msg_getblocktxn,
99+
b"getcfcheckpt": msg_getcfcheckpt,
100+
b"getcfheaders": msg_getcfheaders,
101+
b"getcfilters": msg_getcfilters,
96102
b"getdata": msg_getdata,
97103
b"getheaders": msg_getheaders,
98104
b"getheaders2": msg_getheaders2,

0 commit comments

Comments
 (0)