aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_filter.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2020-04-10 16:01:33 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2020-04-11 18:40:16 +0200
commit1356a45ef042e7bd3d539fbb606d6b1be547d00f (patch)
treed263fcb1b68bc14ebcc0d7fa92f13bef00307ddb /test/functional/p2p_filter.py
parent75917591c840ca61f5e2c6f5858e6882e834a911 (diff)
downloadbitcoin-1356a45ef042e7bd3d539fbb606d6b1be547d00f.tar.xz
test: complete impl. of msg_merkleblock and wait_for_merkleblock
Implements the missing initialization/serialization methods for msg_merkleblock, based on the already present class CMerkleBlock. Also changes the method wait_for_merkleblock() to be more precise by waiting for a merkleblock with a specified blockhash instead of an arbitrary one. In the BIP37 test p2p_filter.py, this new method is used to make the test of receiving merkleblock and tx if a filter is set to be more precise, by checking if they also arrive in the right order.
Diffstat (limited to 'test/functional/p2p_filter.py')
-rwxr-xr-xtest/functional/p2p_filter.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py
index 188b130a57..aa2c92c277 100755
--- a/test/functional/p2p_filter.py
+++ b/test/functional/p2p_filter.py
@@ -14,10 +14,7 @@ from test_framework.messages import (
msg_filteradd,
msg_filterclear,
)
-from test_framework.mininode import (
- P2PInterface,
- mininode_lock,
-)
+from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
@@ -69,18 +66,15 @@ class FilterTest(BitcoinTestFramework):
filter_address = self.nodes[0].decodescript(filter_node.watch_script_pubkey)['addresses'][0]
self.log.info('Check that we receive merkleblock and tx if the filter matches a tx in a block')
- filter_node.merkleblock_received = False
block_hash = self.nodes[0].generatetoaddress(1, filter_address)[0]
txid = self.nodes[0].getblock(block_hash)['tx'][0]
+ filter_node.wait_for_merkleblock(int(block_hash, 16))
filter_node.wait_for_tx(txid)
- assert filter_node.merkleblock_received
self.log.info('Check that we only receive a merkleblock if the filter does not match a tx in a block')
- with mininode_lock:
- filter_node.last_message.pop("merkleblock", None)
filter_node.tx_received = False
- self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())
- filter_node.wait_for_merkleblock()
+ block_hash = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())[0]
+ filter_node.wait_for_merkleblock(int(block_hash, 16))
assert not filter_node.tx_received
self.log.info('Check that we not receive a tx if the filter does not match a mempool tx')