Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-parkedchain.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2018 The Bitcoin developers | # Copyright (c) 2018 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test the parckblock and unparkblock RPC calls.""" | """Test the parkblock and unparkblock RPC calls.""" | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal | from test_framework.util import assert_equal | ||||
class ParkedChainTest(BitcoinTestFramework): | class ParkedChainTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [["-noparkdeepreorg", | self.extra_args = [ | ||||
"-noautomaticunparking", "-whitelist=noban@127.0.0.1"], ["-maxreorgdepth=-1"]] | [ | ||||
"-noparkdeepreorg", | |||||
"-noautomaticunparking", | |||||
"-whitelist=noban@127.0.0.1", | |||||
], | |||||
[ | |||||
"-automaticunparking=1", | |||||
"-maxreorgdepth=-1" | |||||
] | |||||
] | |||||
def skip_test_if_missing_module(self): | def skip_test_if_missing_module(self): | ||||
self.skip_if_no_wallet() | self.skip_if_no_wallet() | ||||
# There should only be one chaintip, which is expected_tip | # There should only be one chaintip, which is expected_tip | ||||
def only_valid_tip(self, expected_tip, other_tip_status=None): | def only_valid_tip(self, expected_tip, other_tip_status=None): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
assert_equal(node.getbestblockhash(), expected_tip) | assert_equal(node.getbestblockhash(), expected_tip) | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.generate(parking_node, 3, sync_fun=self.no_op) | self.generate(parking_node, 3, sync_fun=self.no_op) | ||||
self.generatetoaddress(node, | self.generatetoaddress(node, | ||||
nblocks=5, | nblocks=5, | ||||
address=node.getnewaddress(label='coinbase'), | address=node.getnewaddress(label='coinbase'), | ||||
sync_fun=self.no_op, | sync_fun=self.no_op, | ||||
) | ) | ||||
wait_for_parked_block(node.getbestblockhash()) | wait_for_parked_block(node.getbestblockhash()) | ||||
# Restart the parking node without parkdeepreorg. | # Restart the parking node without parkdeepreorg. | ||||
self.restart_node(1, ["-parkdeepreorg=0"]) | self.restart_node(1, self.extra_args[1] + ["-parkdeepreorg=0"]) | ||||
parking_node = self.nodes[1] | parking_node = self.nodes[1] | ||||
self.connect_nodes(node.index, parking_node.index) | self.connect_nodes(node.index, parking_node.index) | ||||
# The other chain should still be marked 'parked'. | # The other chain should still be marked 'parked'. | ||||
wait_for_parked_block(node.getbestblockhash()) | wait_for_parked_block(node.getbestblockhash()) | ||||
# Three more blocks is not enough to unpark. Even though its PoW is | # Three more blocks is not enough to unpark. Even though its PoW is | ||||
# larger, we are still following the delayed-unparking rules. | # larger, we are still following the delayed-unparking rules. | ||||
self.generate(node, 3, sync_fun=self.no_op) | self.generate(node, 3, sync_fun=self.no_op) | ||||
wait_for_parked_block(node.getbestblockhash()) | wait_for_parked_block(node.getbestblockhash()) | ||||
Show All 10 Lines |