Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_filter.py
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | def set_test_params(self): | ||||
]] | ]] | ||||
def skip_test_if_missing_module(self): | def skip_test_if_missing_module(self): | ||||
self.skip_if_no_wallet() | self.skip_if_no_wallet() | ||||
def run_test(self): | def run_test(self): | ||||
self.log.info('Add filtered P2P connection to the node') | self.log.info('Add filtered P2P connection to the node') | ||||
filter_node = self.nodes[0].add_p2p_connection(FilterNode()) | filter_node = self.nodes[0].add_p2p_connection(FilterNode()) | ||||
filter_node.send_message(filter_node.watch_filter_init) | filter_node.send_and_ping(filter_node.watch_filter_init) | ||||
filter_node.sync_with_ping() | |||||
filter_address = self.nodes[0].decodescript( | filter_address = self.nodes[0].decodescript( | ||||
filter_node.watch_script_pubkey)['addresses'][0] | filter_node.watch_script_pubkey)['addresses'][0] | ||||
self.log.info( | self.log.info( | ||||
'Check that we receive merkleblock and tx if the filter matches a tx in a block') | 'Check that we receive merkleblock and tx if the filter matches a tx in a block') | ||||
filter_node.merkleblock_received = False | filter_node.merkleblock_received = False | ||||
block_hash = self.nodes[0].generatetoaddress(1, filter_address)[0] | block_hash = self.nodes[0].generatetoaddress(1, filter_address)[0] | ||||
txid = self.nodes[0].getblock(block_hash)['tx'][0] | txid = self.nodes[0].getblock(block_hash)['tx'][0] | ||||
Show All 23 Lines | def run_test(self): | ||||
'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( | self.log.info( | ||||
'Check that after deleting filter all txs get relayed again') | 'Check that after deleting filter all txs get relayed again') | ||||
filter_node.send_message(msg_filterclear()) | filter_node.send_and_ping(msg_filterclear()) | ||||
filter_node.sync_with_ping() | |||||
for _ in range(5): | for _ in range(5): | ||||
txid = self.nodes[0].sendtoaddress( | txid = self.nodes[0].sendtoaddress( | ||||
self.nodes[0].getnewaddress(), 7) | self.nodes[0].getnewaddress(), 7) | ||||
filter_node.wait_for_tx(txid) | filter_node.wait_for_tx(txid) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
FilterTest().main() | FilterTest().main() |