Changeset View
Changeset View
Standalone View
Standalone View
qa/rpc-tests/import-rescan.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2014-2016 The Bitcoin Core developers | # Copyright (c) 2014-2016 The Bitcoin Core 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 rescan behavior of importaddress, importpubkey, importprivkey, and | Test rescan behavior of importaddress, importpubkey, importprivkey, and | ||||
importmulti RPCs with different types of keys and rescan options. | importmulti RPCs with different types of keys and rescan options. | ||||
In the first part of the test, node 1 creates an address for each type of | In the first part of the test, node 0 creates an address for each type of | ||||
import RPC call and node 0 sends BTC to it. Then other nodes import the | import RPC call and node 0 sends BTC to it. Then other nodes import the | ||||
addresses, and the test makes listtransactions and getbalance calls to confirm | addresses, and the test makes listtransactions and getbalance calls to confirm | ||||
that the importing node either did or did not execute rescans picking up the | that the importing node either did or did not execute rescans picking up the | ||||
send transactions. | send transactions. | ||||
In the second part of the test, node 0 sends more BTC to each address, and the | In the second part of the test, node 0 sends more BTC to each address, and the | ||||
test makes more listtransactions and getbalance calls to confirm that the | test makes more listtransactions and getbalance calls to confirm that the | ||||
importing nodes pick up the new transactions regardless of whether rescans | importing nodes pick up the new transactions regardless of whether rescans | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | |||||
class ImportRescanTest(BitcoinTestFramework): | class ImportRescanTest(BitcoinTestFramework): | ||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.num_nodes = 2 + len(IMPORT_NODES) | self.num_nodes = 2 + len(IMPORT_NODES) | ||||
def setup_network(self): | def setup_network(self): | ||||
extra_args = [["-debug=1"] for _ in range(self.num_nodes)] | extra_args = [[] for _ in range(self.num_nodes)] | ||||
for i, import_node in enumerate(IMPORT_NODES, 2): | for i, import_node in enumerate(IMPORT_NODES, 2): | ||||
if import_node.prune: | if import_node.prune: | ||||
extra_args[i] += ["-prune=1"] | extra_args[i] += ["-prune=1"] | ||||
self.nodes = start_nodes( | self.nodes = start_nodes( | ||||
self.num_nodes, self.options.tmpdir, extra_args) | self.num_nodes, self.options.tmpdir, extra_args) | ||||
for i in range(1, self.num_nodes): | for i in range(1, self.num_nodes): | ||||
connect_nodes(self.nodes[i], 0) | connect_nodes(self.nodes[i], 0) | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |