Skip to content

Commit f5c003d

Browse files
jimpojnewbery
authored andcommitted
[test] Add test for NODE_COMPACT_FILTER.
Test that a node configured to serve compact filters will signal NODE_COMPACT_FILTER service bit.
1 parent 132b30d commit f5c003d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

test/functional/p2p_blockfilters.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Tests NODE_COMPACT_FILTERS (BIP 157/158).
66
7-
Tests that a node configured with -blockfilterindex and -peerblockfilters can serve
8-
cfilters, cfheaders and cfcheckpts.
7+
Tests that a node configured with -blockfilterindex and -peerblockfilters signals
8+
NODE_COMPACT_FILTERS and can serve cfilters, cfheaders and cfcheckpts.
99
"""
1010

1111
from test_framework.messages import (
1212
FILTER_TYPE_BASIC,
13+
NODE_COMPACT_FILTERS,
1314
hash256,
1415
msg_getcfcheckpt,
1516
msg_getcfheaders,
@@ -70,6 +71,14 @@ def run_test(self):
7071
self.nodes[1].generate(1001)
7172
wait_until(lambda: self.nodes[1].getblockcount() == 2000)
7273

74+
# Check that nodes have signalled NODE_COMPACT_FILTERS correctly.
75+
assert node0.nServices & NODE_COMPACT_FILTERS != 0
76+
assert node1.nServices & NODE_COMPACT_FILTERS == 0
77+
78+
# Check that the localservices is as expected.
79+
assert int(self.nodes[0].getnetworkinfo()['localservices'], 16) & NODE_COMPACT_FILTERS != 0
80+
assert int(self.nodes[1].getnetworkinfo()['localservices'], 16) & NODE_COMPACT_FILTERS == 0
81+
7382
self.log.info("get cfcheckpt on chain to be re-orged out.")
7483
request = msg_getcfcheckpt(
7584
filter_type=FILTER_TYPE_BASIC,

test/functional/test_framework/messages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
NODE_GETUTXO = (1 << 1)
5050
NODE_BLOOM = (1 << 2)
5151
NODE_WITNESS = (1 << 3)
52+
NODE_COMPACT_FILTERS = (1 << 6)
5253
NODE_NETWORK_LIMITED = (1 << 10)
5354

5455
MSG_TX = 1

0 commit comments

Comments
 (0)