From 55be2930fbd60056547a85ce6671b09897b958b6 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sun, 13 Dec 2020 17:36:01 +0000 Subject: [PATCH] test: disable "is everyone connected" check in sync_all in blocksigner test Everyone is _not_ connected in this test, so on slow machines where this check triggers (e.g. the CI boxes) the test incorrectly fails. This was also a source of (very infrequent) spurious failures during the rebase. --- test/functional/feature_blocksign.py | 2 +- test/functional/test_framework/test_framework.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/functional/feature_blocksign.py b/test/functional/feature_blocksign.py index 0701016eb9..836c16a69b 100755 --- a/test/functional/feature_blocksign.py +++ b/test/functional/feature_blocksign.py @@ -171,7 +171,7 @@ class BlockSignTest(BitcoinTestFramework): self.nodes[i].submitblock(result["hex"]) # All nodes should be synced in blocks and transactions(mempool should be empty) - self.sync_all() + self.sync_all(expect_disconnected=True) def mine_blocks(self, num_blocks, transactions): for i in range(num_blocks): diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 1ffcadf204..29406955e5 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -604,7 +604,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): self.connect_nodes(1, 2) self.sync_all() - def sync_blocks(self, nodes=None, wait=1, timeout=60): + def sync_blocks(self, nodes=None, wait=1, timeout=60, expect_disconnected=False): """ Wait until everybody has the same tip. sync_blocks needs to be called with an rpc_connections set that has least @@ -618,8 +618,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): best_hash = [x.getbestblockhash() for x in rpc_connections] if best_hash.count(best_hash[0]) == len(rpc_connections): return - # Check that each peer has at least one connection - assert (all([len(x.getpeerinfo()) for x in rpc_connections])) + if not expect_disconnected: + assert (all([len(x.getpeerinfo()) for x in rpc_connections])) time.sleep(wait) raise AssertionError("Block sync timed out after {}s:{}".format( timeout, @@ -649,8 +649,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): "".join("\n {!r}".format(m) for m in pool), )) - def sync_all(self, nodes=None): - self.sync_blocks(nodes) + def sync_all(self, nodes=None, expect_disconnected=False): + self.sync_blocks(nodes, expect_disconnected=expect_disconnected) self.sync_mempools(nodes) def wait_until(self, test_function, timeout=60):