mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #14857: wallet_keypool_topup.py: Test for all keypool address types
0dcac51049 wallet_keypool_topup.py: Test for all keypool address types (Gregory Sanders) Pull request description: To protect against regressions if key scanning is changed. Tree-SHA512: d1c4bb033bafd97203a3f68fb262a501442be947907d67902f0391fbdec39c095196403c7675e602806cc68d7e2d1f552ab339a58346162379978d06dad1c4bb
This commit is contained in:
parent
13ff3d6291
commit
3476d826e7
@ -23,8 +23,8 @@ from test_framework.util import (
|
||||
class KeypoolRestoreTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 2
|
||||
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=100']]
|
||||
self.num_nodes = 4
|
||||
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=100'], ['-keypool=100'], ['-keypool=100']]
|
||||
|
||||
def skip_test_if_missing_module(self):
|
||||
self.skip_if_no_wallet()
|
||||
@ -39,32 +39,42 @@ class KeypoolRestoreTest(BitcoinTestFramework):
|
||||
shutil.copyfile(wallet_path, wallet_backup_path)
|
||||
self.start_node(1, self.extra_args[1])
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
connect_nodes(self.nodes[0], 2)
|
||||
connect_nodes(self.nodes[0], 3)
|
||||
|
||||
self.log.info("Generate keys for wallet")
|
||||
for _ in range(90):
|
||||
addr_oldpool = self.nodes[1].getnewaddress()
|
||||
for _ in range(20):
|
||||
addr_extpool = self.nodes[1].getnewaddress()
|
||||
for i, output_type in enumerate(["legacy"]):
|
||||
|
||||
self.log.info("Send funds to wallet")
|
||||
self.nodes[0].sendtoaddress(addr_oldpool, 10)
|
||||
self.nodes[0].generate(1)
|
||||
self.nodes[0].sendtoaddress(addr_extpool, 5)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_blocks()
|
||||
self.log.info("Generate keys for wallet with address type: {}".format(output_type))
|
||||
idx = i+1
|
||||
for _ in range(90):
|
||||
addr_oldpool = self.nodes[idx].getnewaddress()
|
||||
for _ in range(20):
|
||||
addr_extpool = self.nodes[idx].getnewaddress()
|
||||
|
||||
self.log.info("Restart node with wallet backup")
|
||||
self.stop_node(1)
|
||||
shutil.copyfile(wallet_backup_path, wallet_path)
|
||||
self.start_node(1, self.extra_args[1])
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
self.sync_all()
|
||||
# Make sure we're creating the outputs we expect
|
||||
address_details = self.nodes[idx].validateaddress(addr_extpool)
|
||||
if i == 0:
|
||||
assert(not address_details["isscript"])
|
||||
|
||||
self.log.info("Verify keypool is restored and balance is correct")
|
||||
assert_equal(self.nodes[1].getbalance(), 15)
|
||||
assert_equal(self.nodes[1].listtransactions()[0]['category'], "receive")
|
||||
# Check that we have marked all keys up to the used keypool key as used
|
||||
assert_equal(self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())['hdkeypath'], "m/44'/1'/0'/0/110")
|
||||
self.log.info("Send funds to wallet")
|
||||
self.nodes[0].sendtoaddress(addr_oldpool, 10)
|
||||
self.nodes[0].generate(1)
|
||||
self.nodes[0].sendtoaddress(addr_extpool, 5)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_blocks()
|
||||
|
||||
self.log.info("Restart node with wallet backup")
|
||||
self.stop_node(idx)
|
||||
shutil.copyfile(wallet_backup_path, wallet_path)
|
||||
self.start_node(idx, self.extra_args[idx])
|
||||
connect_nodes(self.nodes[0], idx)
|
||||
self.sync_all()
|
||||
|
||||
self.log.info("Verify keypool is restored and balance is correct")
|
||||
assert_equal(self.nodes[idx].getbalance(), 15)
|
||||
assert_equal(self.nodes[idx].listtransactions()[0]['category'], "receive")
|
||||
# Check that we have marked all keys up to the used keypool key as used
|
||||
assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress())['hdkeypath'], "m/44'/1'/0'/0/110")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user