|
16 | 16 | msg_filterclear,
|
17 | 17 | msg_filterload,
|
18 | 18 | msg_getdata,
|
| 19 | + msg_mempool, |
19 | 20 | )
|
20 | 21 | from test_framework.mininode import P2PInterface
|
21 | 22 | from test_framework.script import MAX_SCRIPT_ELEMENT_SIZE
|
@@ -93,6 +94,20 @@ def test_size_limits(self, filter_node):
|
93 | 94 |
|
94 | 95 | filter_node.send_and_ping(msg_filterclear())
|
95 | 96 |
|
| 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 | + |
96 | 111 | def run_test(self):
|
97 | 112 | filter_node = self.nodes[0].add_p2p_connection(FilterNode())
|
98 | 113 |
|
@@ -123,7 +138,7 @@ def run_test(self):
|
123 | 138 | assert not filter_node.merkleblock_received
|
124 | 139 | assert not filter_node.tx_received
|
125 | 140 |
|
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') |
127 | 142 | filter_node.merkleblock_received = False
|
128 | 143 | txid = self.nodes[0].sendtoaddress(filter_address, 90)
|
129 | 144 | filter_node.wait_for_tx(txid)
|
@@ -152,7 +167,9 @@ def run_test(self):
|
152 | 167 | self.log.info("Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed")
|
153 | 168 | filter_node.send_and_ping(msg_filterload(data=b'', nHashFuncs=1))
|
154 | 169 | filter_node.send_and_ping(msg_filteradd(data=b'letstrytocrashthisnode'))
|
| 170 | + self.nodes[0].disconnect_p2ps() |
155 | 171 |
|
| 172 | + self.test_msg_mempool() |
156 | 173 |
|
157 | 174 | if __name__ == '__main__':
|
158 | 175 | FilterTest().main()
|
0 commit comments