Skip to content

Commit

Permalink
sync_blocks: Increase debugging to hunt down mempool_reorg intermitte…
Browse files Browse the repository at this point in the history
…nt failure

Coming from btc@fac2fc4dd8a28b99e17c57e4ab6580a3231f1d0a
  • Loading branch information
furszy committed Jul 3, 2020
1 parent dd7855c commit 38efbb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 2 additions & 4 deletions test/functional/mempool_reorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ def set_test_params(self):
self.num_nodes = 2
self.extra_args = [["-checkmempool"]] * 2

alert_filename = None # Set by setup_network

def run_test(self):
# Start with a 200 block chain
assert_equal(self.nodes[0].getblockcount(), 200)
Expand Down Expand Up @@ -74,9 +72,8 @@ def run_test(self):
spend_101_id = self.nodes[0].sendrawtransaction(spend_101_raw)
spend_102_1_id = self.nodes[0].sendrawtransaction(spend_102_1_raw)

self.sync_all()

assert_equal(set(self.nodes[0].getrawmempool()), {spend_101_id, spend_102_1_id})
self.sync_all()

for node in self.nodes:
node.invalidateblock(last_block[0])
Expand All @@ -91,6 +88,7 @@ def run_test(self):

# mempool should be empty.
assert_equal(set(self.nodes[0].getrawmempool()), set())
self.sync_all()

if __name__ == '__main__':
MempoolCoinbaseTest().main()
11 changes: 8 additions & 3 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,10 @@ def sync_blocks(rpc_connections, *, wait=1, timeout=60):
# Check that each peer has at least one connection
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
time.sleep(wait)
raise AssertionError("Block sync timed out:{}".format("".join("\n {!r}".format(b) for b in best_hash)))
raise AssertionError("Block sync timed out after {}s:{}".format(
timeout,
"".join("\n {!r}".format(b) for b in best_hash),
))

def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
"""
Expand All @@ -406,8 +409,10 @@ def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True):
# Check that each peer has at least one connection
assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
time.sleep(wait)
raise AssertionError("Mempool sync timed out:{}".format("".join("\n {!r}".format(m) for m in pool)))

raise AssertionError("Mempool sync timed out after {}s:{}".format(
timeout,
"".join("\n {!r}".format(m) for m in pool),
))

# Transaction/Block functions
#############################
Expand Down

0 comments on commit 38efbb9

Please sign in to comment.