diff options
author | gzhao408 <gzhao408@berkeley.edu> | 2020-05-10 09:39:30 -0700 |
---|---|---|
committer | gzhao408 <gzhao408@berkeley.edu> | 2020-06-10 07:27:58 -0700 |
commit | e8acc6015695c8439fc971a12709468995b96dcf (patch) | |
tree | d8d98eb85d7c2af53552c4f006fe45354bf9db61 /test | |
parent | b3091b2be7d1e5ab86d7380a884d4f23a5e9c9b7 (diff) | |
download | bitcoin-e8acc6015695c8439fc971a12709468995b96dcf.tar.xz |
[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
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/p2p_filter.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py index 15955a938c..7dc0368ee1 100755 --- a/test/functional/p2p_filter.py +++ b/test/functional/p2p_filter.py @@ -16,6 +16,7 @@ from test_framework.messages import ( msg_filterclear, msg_filterload, msg_getdata, + msg_mempool, ) from test_framework.mininode import P2PInterface from test_framework.script import MAX_SCRIPT_ELEMENT_SIZE @@ -93,6 +94,20 @@ class FilterTest(BitcoinTestFramework): filter_node.send_and_ping(msg_filterclear()) + def test_msg_mempool(self): + self.log.info("Check that a node with bloom filters enabled services p2p mempool messages") + filter_peer = FilterNode() + + self.log.info("Create a tx relevant to the peer before connecting") + filter_address = self.nodes[0].decodescript(filter_peer.watch_script_pubkey)['addresses'][0] + txid = self.nodes[0].sendtoaddress(filter_address, 90) + + self.log.info("Send a mempool msg after connecting and check that the tx is received") + self.nodes[0].add_p2p_connection(filter_peer) + filter_peer.send_and_ping(filter_peer.watch_filter_init) + self.nodes[0].p2p.send_message(msg_mempool()) + filter_peer.wait_for_tx(txid) + def run_test(self): filter_node = self.nodes[0].add_p2p_connection(FilterNode()) @@ -123,7 +138,7 @@ class FilterTest(BitcoinTestFramework): assert not filter_node.merkleblock_received assert not filter_node.tx_received - self.log.info('Check that we receive a tx in reply to a mempool msg if the filter matches a mempool tx') + self.log.info('Check that we receive a tx if the filter matches a mempool tx') filter_node.merkleblock_received = False txid = self.nodes[0].sendtoaddress(filter_address, 90) filter_node.wait_for_tx(txid) @@ -152,7 +167,9 @@ class FilterTest(BitcoinTestFramework): self.log.info("Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed") filter_node.send_and_ping(msg_filterload(data=b'', nHashFuncs=1)) filter_node.send_and_ping(msg_filteradd(data=b'letstrytocrashthisnode')) + self.nodes[0].disconnect_p2ps() + self.test_msg_mempool() if __name__ == '__main__': FilterTest().main() |