mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-13 02:27:00 +02:00
Merge #15773: test: Add BitcoinTestFramework::sync_* methods
fafe5f0d09
test: Remove unused imports (MarcoFalke)fa16a09215
scripted-diff: use self.sync_* methods (MarcoFalke)faf77f9b90
test: Pass self to test_simple_bumpfee_succeeds (MarcoFalke)fa6dc7c5c3
test: Add BitcoinTestFramework::sync_* methods (MarcoFalke)fafe008cb4
test: Pass at most one node group to sync_all (MarcoFalke)fa4680ed09
scripted-diff: Rename sync_blocks to send_blocks to avoid name collisions and confusion (MarcoFalke) Pull request description: This adds methods to the test framework that can be called by just `self.sync_*()`. This avoids having to import the underlying util method. Also, in the default case, where all nodes are synced this avoid having to pass `self.nodes` explicitly. So the effective changes are: ```diff @@ -from test_framework.util import sync_blocks, sync_mempools @@ - sync_blocks(self.nodes) + self.sync_blocks() @@ - sync_mempools(self.nodes) + self.sync_mempools() ACKs for commit fafe5f: promag: utACKfafe5f0
. jonatack: ACKfafe5f0d09
, nice simplification. Tree-SHA512: 5c81840edf9fb3c5de2d7bf95ca36a5a8d23567cd1479a0f4044547c2080e9a3c5cf375357bc8eebb5b68829be050a171ab2512cfd47b89feed51fe3bad2cd72
This commit is contained in:
@ -396,7 +396,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
"""
|
||||
disconnect_nodes(self.nodes[1], 2)
|
||||
disconnect_nodes(self.nodes[2], 1)
|
||||
self.sync_all([self.nodes[:2], self.nodes[2:]])
|
||||
self.sync_all(self.nodes[:2])
|
||||
self.sync_all(self.nodes[2:])
|
||||
|
||||
def join_network(self):
|
||||
"""
|
||||
@ -405,13 +406,15 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
connect_nodes_bi(self.nodes, 1, 2)
|
||||
self.sync_all()
|
||||
|
||||
def sync_all(self, node_groups=None):
|
||||
if not node_groups:
|
||||
node_groups = [self.nodes]
|
||||
def sync_blocks(self, nodes=None, **kwargs):
|
||||
sync_blocks(nodes or self.nodes, **kwargs)
|
||||
|
||||
for group in node_groups:
|
||||
sync_blocks(group)
|
||||
sync_mempools(group)
|
||||
def sync_mempools(self, nodes=None, **kwargs):
|
||||
sync_mempools(nodes or self.nodes, **kwargs)
|
||||
|
||||
def sync_all(self, nodes=None, **kwargs):
|
||||
self.sync_blocks(nodes, **kwargs)
|
||||
self.sync_mempools(nodes, **kwargs)
|
||||
|
||||
# Private helper methods. These should not be accessed by the subclass test scripts.
|
||||
|
||||
@ -497,7 +500,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
# see the tip age check in IsInitialBlockDownload().
|
||||
for i in range(8):
|
||||
self.nodes[0].generatetoaddress(25 if i != 7 else 24, self.nodes[i % 4].get_deterministic_priv_key().address)
|
||||
sync_blocks(self.nodes)
|
||||
self.sync_blocks()
|
||||
|
||||
for n in self.nodes:
|
||||
assert_equal(n.getblockchaininfo()["blocks"], 199)
|
||||
|
Reference in New Issue
Block a user