aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
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/test_framework
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/test_framework')
-rwxr-xr-xtest/functional/test_framework/messages.py15
-rwxr-xr-xtest/functional/test_framework/mininode.py5
2 files changed, 16 insertions, 4 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index 5f8fcc6fd8..45b49bcf9e 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -1321,10 +1321,23 @@ class msg_headers:
class msg_merkleblock:
+ __slots__ = ("merkleblock",)
command = b"merkleblock"
+ def __init__(self, merkleblock=None):
+ if merkleblock is None:
+ self.merkleblock = CMerkleBlock()
+ else:
+ self.merkleblock = merkleblock
+
def deserialize(self, f):
- pass # Placeholder for now
+ self.merkleblock.deserialize(f)
+
+ def serialize(self):
+ return self.merkleblock.serialize()
+
+ def __repr__(self):
+ return "msg_merkleblock(merkleblock=%s)" % (repr(self.merkleblock))
class msg_filterload:
diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py
index ad330f2a93..b17254faf8 100755
--- a/test/functional/test_framework/mininode.py
+++ b/test/functional/test_framework/mininode.py
@@ -397,14 +397,13 @@ class P2PInterface(P2PConnection):
wait_until(test_function, timeout=timeout, lock=mininode_lock)
- def wait_for_merkleblock(self, timeout=60):
+ def wait_for_merkleblock(self, blockhash, timeout=60):
def test_function():
assert self.is_connected
last_filtered_block = self.last_message.get('merkleblock')
if not last_filtered_block:
return False
- # TODO change this method to take a hash value and only return true if the correct block has been received
- return True
+ return last_filtered_block.merkleblock.header.rehash() == blockhash
wait_until(test_function, timeout=timeout, lock=mininode_lock)