mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Merge #19122: test: Add missing sync_blocks to wallet_hd
fa7d3a8890
test: Add missing sync_blocks to wallet_hd (MarcoFalke)eeeed51f58
test: pep-8 wallet_hd (MarcoFalke) Pull request description: This fixes the ` test_framework.authproxy.JSONRPCException: non-final (-26)` error when node 1 is one block behind of node 0. (height 122 vs 123) ACKs for top commit: promag: Code review ACKfa7d3a8890
. Tree-SHA512: b549dce2e08c58b949168ed2013bfa176802c963d0d7e890f643c8792da5dade14d91441dfa74372f1f1d34d696e8900a2b60b4861c0ba2dce99f2a633ab27ff
This commit is contained in:
commit
45a1489997
1 changed files with 32 additions and 20 deletions
|
@ -11,7 +11,7 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.util import (
|
||||
assert_equal,
|
||||
connect_nodes,
|
||||
assert_raises_rpc_error
|
||||
assert_raises_rpc_error,
|
||||
)
|
||||
|
||||
|
||||
|
@ -82,7 +82,10 @@ class WalletHDTest(BitcoinTestFramework):
|
|||
# otherwise node1 would auto-recover all funds in flag the keypool keys as used
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks"))
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate"))
|
||||
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, 'wallets', "wallet.dat"))
|
||||
shutil.copyfile(
|
||||
os.path.join(self.nodes[1].datadir, "hd.bak"),
|
||||
os.path.join(self.nodes[1].datadir, self.chain, 'wallets', "wallet.dat"),
|
||||
)
|
||||
self.start_node(1)
|
||||
|
||||
# Assert that derivation is deterministic
|
||||
|
@ -108,7 +111,10 @@ class WalletHDTest(BitcoinTestFramework):
|
|||
self.stop_node(1)
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks"))
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate"))
|
||||
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat"))
|
||||
shutil.copyfile(
|
||||
os.path.join(self.nodes[1].datadir, "hd.bak"),
|
||||
os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat"),
|
||||
)
|
||||
self.start_node(1, extra_args=self.extra_args[1])
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
self.sync_all()
|
||||
|
@ -142,7 +148,8 @@ class WalletHDTest(BitcoinTestFramework):
|
|||
new_masterkeyid = self.nodes[1].getwalletinfo()['hdseedid']
|
||||
assert orig_masterkeyid != new_masterkeyid
|
||||
addr = self.nodes[1].getnewaddress()
|
||||
assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/0\'') # Make sure the new address is the first from the keypool
|
||||
# Make sure the new address is the first from the keypool
|
||||
assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/0\'')
|
||||
self.nodes[1].keypoolrefill(1) # Fill keypool with 1 key
|
||||
|
||||
# Set a new HD seed on node 1 without flushing the keypool
|
||||
|
@ -153,13 +160,15 @@ class WalletHDTest(BitcoinTestFramework):
|
|||
assert orig_masterkeyid != new_masterkeyid
|
||||
addr = self.nodes[1].getnewaddress()
|
||||
assert_equal(orig_masterkeyid, self.nodes[1].getaddressinfo(addr)['hdseedid'])
|
||||
assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/1\'') # Make sure the new address continues previous keypool
|
||||
# Make sure the new address continues previous keypool
|
||||
assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/1\'')
|
||||
|
||||
# Check that the next address is from the new seed
|
||||
self.nodes[1].keypoolrefill(1)
|
||||
next_addr = self.nodes[1].getnewaddress()
|
||||
assert_equal(new_masterkeyid, self.nodes[1].getaddressinfo(next_addr)['hdseedid'])
|
||||
assert_equal(self.nodes[1].getaddressinfo(next_addr)['hdkeypath'], 'm/0\'/0\'/0\'') # Make sure the new address is not from previous keypool
|
||||
# Make sure the new address is not from previous keypool
|
||||
assert_equal(self.nodes[1].getaddressinfo(next_addr)['hdkeypath'], 'm/0\'/0\'/0\'')
|
||||
assert next_addr != addr
|
||||
|
||||
# Sethdseed parameter validity
|
||||
|
@ -222,6 +231,7 @@ class WalletHDTest(BitcoinTestFramework):
|
|||
txid = self.nodes[0].sendtoaddress(addr, 1)
|
||||
origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex'])
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_blocks()
|
||||
origin_rpc.gettransaction(txid)
|
||||
assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', restore_rpc.gettransaction, txid)
|
||||
out_of_kp_txid = txid
|
||||
|
@ -232,6 +242,7 @@ class WalletHDTest(BitcoinTestFramework):
|
|||
txid = self.nodes[0].sendtoaddress(last_addr, 1)
|
||||
origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex'])
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_blocks()
|
||||
origin_rpc.gettransaction(txid)
|
||||
restore_rpc.gettransaction(txid)
|
||||
assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', restore_rpc.gettransaction, out_of_kp_txid)
|
||||
|
@ -266,5 +277,6 @@ class WalletHDTest(BitcoinTestFramework):
|
|||
info = restore2_rpc.getaddressinfo(addr)
|
||||
assert_equal(info['ismine'], False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletHDTest().main()
|
||||
|
|
Loading…
Add table
Reference in a new issue