Skip to content

Commit e8acc60

Browse files
committed
[test] add mempool msg test for node with bloomfilter enabled
-msg_mempool is currently only tested with bloomfilter disabled (node is disconnected) in p2p_mempool.py -msg_mempool should get mempool txns in response when bloomfilter is enabled -edit test that doesn't test msg_mempool as intended
1 parent b3091b2 commit e8acc60

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/functional/p2p_filter.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
msg_filterclear,
1717
msg_filterload,
1818
msg_getdata,
19+
msg_mempool,
1920
)
2021
from test_framework.mininode import P2PInterface
2122
from test_framework.script import MAX_SCRIPT_ELEMENT_SIZE
@@ -93,6 +94,20 @@ def test_size_limits(self, filter_node):
9394

9495
filter_node.send_and_ping(msg_filterclear())
9596

97+
def test_msg_mempool(self):
98+
self.log.info("Check that a node with bloom filters enabled services p2p mempool messages")
99+
filter_peer = FilterNode()
100+
101+
self.log.info("Create a tx relevant to the peer before connecting")
102+
filter_address = self.nodes[0].decodescript(filter_peer.watch_script_pubkey)['addresses'][0]
103+
txid = self.nodes[0].sendtoaddress(filter_address, 90)
104+
105+
self.log.info("Send a mempool msg after connecting and check that the tx is received")
106+
self.nodes[0].add_p2p_connection(filter_peer)
107+
filter_peer.send_and_ping(filter_peer.watch_filter_init)
108+
self.nodes[0].p2p.send_message(msg_mempool())
109+
filter_peer.wait_for_tx(txid)
110+
96111
def run_test(self):
97112
filter_node = self.nodes[0].add_p2p_connection(FilterNode())
98113

@@ -123,7 +138,7 @@ def run_test(self):
123138
assert not filter_node.merkleblock_received
124139
assert not filter_node.tx_received
125140

126-
self.log.info('Check that we receive a tx in reply to a mempool msg if the filter matches a mempool tx')
141+
self.log.info('Check that we receive a tx if the filter matches a mempool tx')
127142
filter_node.merkleblock_received = False
128143
txid = self.nodes[0].sendtoaddress(filter_address, 90)
129144
filter_node.wait_for_tx(txid)
@@ -152,7 +167,9 @@ def run_test(self):
152167
self.log.info("Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed")
153168
filter_node.send_and_ping(msg_filterload(data=b'', nHashFuncs=1))
154169
filter_node.send_and_ping(msg_filteradd(data=b'letstrytocrashthisnode'))
170+
self.nodes[0].disconnect_p2ps()
155171

172+
self.test_msg_mempool()
156173

157174
if __name__ == '__main__':
158175
FilterTest().main()

0 commit comments

Comments
 (0)