Browse Source

[QA] extend wallet-hd test to cover HD metadata

0.13
Jonas Schnelli 8 years ago
parent
commit
f70808596f
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 10
      qa/rpc-tests/wallet-hd.py

10
qa/rpc-tests/wallet-hd.py

@ -30,6 +30,10 @@ class WalletHDTest(BitcoinTestFramework): @@ -30,6 +30,10 @@ class WalletHDTest(BitcoinTestFramework):
def run_test (self):
tmpdir = self.options.tmpdir
# Make sure we use hd, keep masterkeyid
masterkeyid = self.nodes[1].getwalletinfo()['masterkeyid']
assert_equal(len(masterkeyid), 40)
# Import a non-HD private key in the HD wallet
non_hd_add = self.nodes[0].getnewaddress()
self.nodes[1].importprivkey(self.nodes[0].dumpprivkey(non_hd_add))
@ -45,6 +49,9 @@ class WalletHDTest(BitcoinTestFramework): @@ -45,6 +49,9 @@ class WalletHDTest(BitcoinTestFramework):
num_hd_adds = 300
for _ in range(num_hd_adds):
hd_add = self.nodes[1].getnewaddress()
hd_info = self.nodes[1].validateaddress(hd_add)
assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(_+1)+"'")
assert_equal(hd_info["hdmasterkeyid"], masterkeyid)
self.nodes[0].sendtoaddress(hd_add, 1)
self.nodes[0].generate(1)
self.nodes[0].sendtoaddress(non_hd_add, 1)
@ -64,6 +71,9 @@ class WalletHDTest(BitcoinTestFramework): @@ -64,6 +71,9 @@ class WalletHDTest(BitcoinTestFramework):
hd_add_2 = None
for _ in range(num_hd_adds):
hd_add_2 = self.nodes[1].getnewaddress()
hd_info_2 = self.nodes[1].validateaddress(hd_add_2)
assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(_+1)+"'")
assert_equal(hd_info_2["hdmasterkeyid"], masterkeyid)
assert_equal(hd_add, hd_add_2)
# Needs rescan

Loading…
Cancel
Save