Skip to content

Commit e016c00

Browse files
author
MacroFake
committed
Merge bitcoin/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/bitcoin@5dc6d92) Tree-SHA512: d656c4d38a856373f01d7c293ae7d2b27378a9fc248048ebf2a64725ef8b498b3ddf4f420704abdb20d0c68ca548f1777602c5e73b66821a20c97ae618f1d63f
2 parents 002411d + 5dc6d92 commit e016c00

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
@@ -1672,7 +1672,7 @@ class msg_getcfilters:
16721672
__slots__ = ("filter_type", "start_height", "stop_hash")
16731673
msgtype = b"getcfilters"
16741674

1675-
def __init__(self, filter_type, start_height, stop_hash):
1675+
def __init__(self, filter_type=None, start_height=None, stop_hash=None):
16761676
self.filter_type = filter_type
16771677
self.start_height = start_height
16781678
self.stop_hash = stop_hash
@@ -1722,7 +1722,7 @@ class msg_getcfheaders:
17221722
__slots__ = ("filter_type", "start_height", "stop_hash")
17231723
msgtype = b"getcfheaders"
17241724

1725-
def __init__(self, filter_type, start_height, stop_hash):
1725+
def __init__(self, filter_type=None, start_height=None, stop_hash=None):
17261726
self.filter_type = filter_type
17271727
self.start_height = start_height
17281728
self.stop_hash = stop_hash
@@ -1775,7 +1775,7 @@ class msg_getcfcheckpt:
17751775
__slots__ = ("filter_type", "stop_hash")
17761776
msgtype = b"getcfcheckpt"
17771777

1778-
def __init__(self, filter_type, stop_hash):
1778+
def __init__(self, filter_type=None, stop_hash=None):
17791779
self.filter_type = filter_type
17801780
self.stop_hash = stop_hash
17811781

test/functional/test_framework/p2p.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
msg_getaddr,
4848
msg_getblocks,
4949
msg_getblocktxn,
50+
msg_getcfcheckpt,
51+
msg_getcfheaders,
52+
msg_getcfilters,
5053
msg_getdata,
5154
msg_getheaders,
5255
msg_headers,
@@ -108,6 +111,9 @@
108111
b"getaddr": msg_getaddr,
109112
b"getblocks": msg_getblocks,
110113
b"getblocktxn": msg_getblocktxn,
114+
b"getcfcheckpt": msg_getcfcheckpt,
115+
b"getcfheaders": msg_getcfheaders,
116+
b"getcfilters": msg_getcfilters,
111117
b"getdata": msg_getdata,
112118
b"getheaders": msg_getheaders,
113119
b"headers": msg_headers,

0 commit comments

Comments
 (0)