Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet-dump.py
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | with open(file_name, encoding='utf8') as inputfile: | ||||
break | break | ||||
elif keytype == "reserve=1": | elif keytype == "reserve=1": | ||||
found_addr_rsv += 1 | found_addr_rsv += 1 | ||||
break | break | ||||
return found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_ret | return found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_ret | ||||
class WalletDumpTest(BitcoinTestFramework): | class WalletDumpTest(BitcoinTestFramework): | ||||
def set_test_params(self): | |||||
def __init__(self): | |||||
super().__init__() | |||||
self.setup_clean_chain = False | |||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [["-keypool=90"]] | self.extra_args = [["-keypool=90"]] | ||||
def setup_network(self, split=False): | def setup_network(self, split=False): | ||||
# Use 1 minute timeout because the initial getnewaddress RPC can take | # Use 1 minute timeout because the initial getnewaddress RPC can take | ||||
# longer than the default 30 seconds due to an expensive | # longer than the default 30 seconds due to an expensive | ||||
# CWallet::TopUpKeyPool call, and the encryptwallet RPC made later in | # CWallet::TopUpKeyPool call, and the encryptwallet RPC made later in | ||||
# the test often takes even longer. | # the test often takes even longer. | ||||
self.nodes = self.start_nodes( | self.add_nodes(self.num_nodes, self.extra_args, timewait=60) | ||||
self.num_nodes, self.options.tmpdir, self.extra_args, timewait=60) | self.start_nodes() | ||||
def run_test(self): | def run_test(self): | ||||
tmpdir = self.options.tmpdir | tmpdir = self.options.tmpdir | ||||
# generate 20 addresses to compare against the dump | # generate 20 addresses to compare against the dump | ||||
test_addr_count = 20 | test_addr_count = 20 | ||||
addrs = [] | addrs = [] | ||||
for i in range(0, test_addr_count): | for i in range(0, test_addr_count): | ||||
Show All 12 Lines | def run_test(self): | ||||
assert_equal(found_addr, test_addr_count) | assert_equal(found_addr, test_addr_count) | ||||
# all keys must be in the dump | # all keys must be in the dump | ||||
assert_equal(found_addr_chg, 50) # 50 blocks where mined | assert_equal(found_addr_chg, 50) # 50 blocks where mined | ||||
# 90 keys plus 100% internal keys | # 90 keys plus 100% internal keys | ||||
assert_equal(found_addr_rsv, 90 * 2) | assert_equal(found_addr_rsv, 90 * 2) | ||||
# encrypt wallet, restart, unlock and dump | # encrypt wallet, restart, unlock and dump | ||||
self.nodes[0].node_encrypt_wallet('test') | self.nodes[0].node_encrypt_wallet('test') | ||||
self.nodes[0] = self.start_node( | self.start_node(0) | ||||
0, self.options.tmpdir, self.extra_args[0]) | |||||
self.nodes[0].walletpassphrase('test', 10) | self.nodes[0].walletpassphrase('test', 10) | ||||
# Should be a no-op: | # Should be a no-op: | ||||
self.nodes[0].keypoolrefill() | self.nodes[0].keypoolrefill() | ||||
self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.encrypted.dump") | self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.encrypted.dump") | ||||
found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_enc = \ | found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_enc = \ | ||||
read_dump( | read_dump( | ||||
tmpdir + "/node0/wallet.encrypted.dump", addrs, hd_master_addr_unenc) | tmpdir + "/node0/wallet.encrypted.dump", addrs, hd_master_addr_unenc) | ||||
assert_equal(found_addr, test_addr_count) | assert_equal(found_addr, test_addr_count) | ||||
# old reserve keys are marked as change now | # old reserve keys are marked as change now | ||||
assert_equal(found_addr_chg, 90 * 2 + 50) | assert_equal(found_addr_chg, 90 * 2 + 50) | ||||
assert_equal(found_addr_rsv, 90 * 2) | assert_equal(found_addr_rsv, 90 * 2) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
WalletDumpTest().main() | WalletDumpTest().main() |