aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/p2p-compactblocks.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2016-10-11 11:54:57 +0200
committerMarcoFalke <falke.marco@gmail.com>2016-10-11 11:55:28 +0200
commit94688d8e43e70f0d5c6ce3f5b6e1bb062ee4540a (patch)
tree6dd0c06fde7c8e166ea1bb8f284c6266a72c5767 /qa/rpc-tests/p2p-compactblocks.py
parenta916677ace1c214f1c87f3a383cdc0d38dee8831 (diff)
parent5e0dd9e07c02422a263cc14a173d4ee21a7c1393 (diff)
downloadbitcoin-94688d8e43e70f0d5c6ce3f5b6e1bb062ee4540a.tar.xz
Merge #8866: [0.13] Backports
5e0dd9e [Doc] Update bips.md for Segregated Witness (fanquake) d6c83b9 [qa] Fix race condition in sendheaders.py (Suhas Daftuar) b73f065 [qa] Another attempt to fix race condition in p2p-compactblocks.py (Suhas Daftuar) b987348 Bugfix: Trivial: RPC: getblockchaininfo help: pruneheight is the lowest, not highest, block (Luke Dashjr) cbc3fe5 test: Explicitly set encoding to utf8 when opening text files (Wladimir J. van der Laan) 0bee740 [qa] util: Move wait_bitcoinds() into stop_nodes() (MarcoFalke) 794b007 [qa] Add getinfo smoke tests and rework versionbits test (MarcoFalke) 1f60d45 [qa] mininode: Only allow named args in wait_until (MarcoFalke) 624a007 [qa] Fix race condition in p2p-compactblocks test (Suhas Daftuar) 3e4abb5 Fix nulldummy.py test (Johnson Lau) 31ab2f8 test: Avoid ConnectionResetErrors during RPC tests (Wladimir J. van der Laan) eb18cc1 bitcoin-util-test.py should fail if the output file is empty (jnewbery) d87227d [qa] nulldummy: Don't run unused code (MarcoFalke) 1dd1783 [qa] blockstore: Switch to dumb dbm (MarcoFalke) 83ad563 [rpc] throw JSONRPCError when utxo set can not be read (MarcoFalke) 6288659 [Wallet] remove "unused" ThreadFlushWalletDB from removeprunedfunds (Jonas Schnelli) 2a8bca4 Add bitcoin-tx JSON tests (jnewbery) 9bbe66e [qa] Split up slow RPC calls to avoid pruning test timeouts (Suhas Daftuar) 375437c Ping regularly in p2p-segwit.py to keep connection alive (Johnson Lau)
Diffstat (limited to 'qa/rpc-tests/p2p-compactblocks.py')
-rwxr-xr-xqa/rpc-tests/p2p-compactblocks.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/qa/rpc-tests/p2p-compactblocks.py b/qa/rpc-tests/p2p-compactblocks.py
index bf4fb43add..cd68043769 100755
--- a/qa/rpc-tests/p2p-compactblocks.py
+++ b/qa/rpc-tests/p2p-compactblocks.py
@@ -28,6 +28,10 @@ class TestNode(SingleNodeConnCB):
self.last_getblocktxn = None
self.last_block = None
self.last_blocktxn = None
+ # Store the hashes of blocks we've seen announced.
+ # This is for synchronizing the p2p message traffic,
+ # so we can eg wait until a particular block is announced.
+ self.set_announced_blockhashes = set()
def on_sendcmpct(self, conn, message):
self.last_sendcmpct = message
@@ -38,14 +42,22 @@ class TestNode(SingleNodeConnCB):
def on_cmpctblock(self, conn, message):
self.last_cmpctblock = message
self.block_announced = True
+ self.last_cmpctblock.header_and_shortids.header.calc_sha256()
+ self.set_announced_blockhashes.add(self.last_cmpctblock.header_and_shortids.header.sha256)
def on_headers(self, conn, message):
self.last_headers = message
self.block_announced = True
+ for x in self.last_headers.headers:
+ x.calc_sha256()
+ self.set_announced_blockhashes.add(x.sha256)
def on_inv(self, conn, message):
self.last_inv = message
- self.block_announced = True
+ for x in self.last_inv.inv:
+ if x.type == 2:
+ self.block_announced = True
+ self.set_announced_blockhashes.add(x.hash)
def on_getdata(self, conn, message):
self.last_getdata = message
@@ -85,6 +97,12 @@ class TestNode(SingleNodeConnCB):
assert(self.received_block_announcement())
self.clear_block_announcement()
+ # Block until a block announcement for a particular block hash is
+ # received.
+ def wait_for_block_announcement(self, block_hash, timeout=30):
+ def received_hash():
+ return (block_hash in self.set_announced_blockhashes)
+ return wait_until(received_hash, timeout=timeout)
class CompactBlocksTest(BitcoinTestFramework):
def __init__(self):
@@ -237,6 +255,10 @@ class CompactBlocksTest(BitcoinTestFramework):
for i in range(num_transactions):
self.nodes[0].sendtoaddress(address, 0.1)
+ # Wait until we've seen the block announcement for the resulting tip
+ tip = int(self.nodes[0].getbestblockhash(), 16)
+ assert(self.test_node.wait_for_block_announcement(tip))
+
# Now mine a block, and look at the resulting compact block.
self.test_node.clear_block_announcement()
block_hash = int(self.nodes[0].generate(1)[0], 16)