Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_filter.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2020 The Bitcoin Core developers | # Copyright (c) 2020 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
""" | """ | ||||
Test BIP 37 | Test BIP 37 | ||||
""" | """ | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
MSG_BLOCK, | MSG_BLOCK, | ||||
MSG_FILTERED_BLOCK, | MSG_FILTERED_BLOCK, | ||||
msg_getdata, | msg_getdata, | ||||
msg_filterload, | msg_filterload, | ||||
msg_filterclear, | |||||
) | ) | ||||
from test_framework.mininode import ( | from test_framework.mininode import ( | ||||
P2PInterface, | P2PInterface, | ||||
mininode_lock, | mininode_lock, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.log.info( | self.log.info( | ||||
'Check that we receive a tx in reply to a mempool msg if the filter matches a mempool tx') | 'Check that we receive a tx in reply to a mempool msg if the filter matches a mempool tx') | ||||
filter_node.merkleblock_received = False | filter_node.merkleblock_received = False | ||||
txid = self.nodes[0].sendtoaddress(filter_address, 90) | txid = self.nodes[0].sendtoaddress(filter_address, 90) | ||||
filter_node.wait_for_tx(txid) | filter_node.wait_for_tx(txid) | ||||
assert not filter_node.merkleblock_received | assert not filter_node.merkleblock_received | ||||
self.log.info( | |||||
'Check that after deleting filter all txs get relayed again') | |||||
filter_node.send_message(msg_filterclear()) | |||||
filter_node.sync_with_ping() | |||||
for _ in range(5): | |||||
txid = self.nodes[0].sendtoaddress( | |||||
self.nodes[0].getnewaddress(), 7) | |||||
filter_node.wait_for_tx(txid) | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
FilterTest().main() | FilterTest().main() |