Actually test that displayaddress is returning correct output
This commit is contained in:
parent
0974f6944c
commit
54bd6687cc
@ -460,9 +460,20 @@ class TestDisplayAddress(DeviceTestCase):
|
|||||||
self.assertEqual(result['code'], -7)
|
self.assertEqual(result['code'], -7)
|
||||||
|
|
||||||
def test_display_address_path(self):
|
def test_display_address_path(self):
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--path', 'm/44h/1h/0h/0/0'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--path', 'm/44h/1h/0h/0/0'])
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--sh_wpkh', '--path', 'm/49h/1h/0h/0/0'])
|
self.assertNotIn('error', result)
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--wpkh', '--path', 'm/84h/1h/0h/0/0'])
|
self.assertNotIn('code', result)
|
||||||
|
self.assertIn('address', result)
|
||||||
|
|
||||||
|
result = self.do_command(self.dev_args + ['displayaddress', '--sh_wpkh', '--path', 'm/49h/1h/0h/0/0'])
|
||||||
|
self.assertNotIn('error', result)
|
||||||
|
self.assertNotIn('code', result)
|
||||||
|
self.assertIn('address', result)
|
||||||
|
|
||||||
|
result = self.do_command(self.dev_args + ['displayaddress', '--wpkh', '--path', 'm/84h/1h/0h/0/0'])
|
||||||
|
self.assertNotIn('error', result)
|
||||||
|
self.assertNotIn('code', result)
|
||||||
|
self.assertIn('address', result)
|
||||||
|
|
||||||
def test_display_address_bad_path(self):
|
def test_display_address_bad_path(self):
|
||||||
result = self.do_command(self.dev_args + ['displayaddress', '--path', 'f'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--path', 'f'])
|
||||||
@ -474,31 +485,43 @@ class TestDisplayAddress(DeviceTestCase):
|
|||||||
legacy_account_xpub = self.do_command(self.dev_args + ['getxpub', 'm/44h/1h/0h'])['xpub']
|
legacy_account_xpub = self.do_command(self.dev_args + ['getxpub', 'm/44h/1h/0h'])['xpub']
|
||||||
|
|
||||||
# Native SegWit address using xpub:
|
# Native SegWit address using xpub:
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h)]' + account_xpub + '/0/0)'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h]' + account_xpub + '/0/0)'])
|
||||||
|
self.assertNotIn('error', result)
|
||||||
|
self.assertNotIn('code', result)
|
||||||
|
self.assertIn('address', result)
|
||||||
|
|
||||||
# Native SegWit address using hex encoded pubkey:
|
# Native SegWit address using hex encoded pubkey:
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h)]' + xpub_to_pub_hex(account_xpub) + '/0/0)'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h]' + xpub_to_pub_hex(account_xpub) + '/0/0)'])
|
||||||
|
self.assertNotIn('error', result)
|
||||||
|
self.assertNotIn('code', result)
|
||||||
|
self.assertIn('address', result)
|
||||||
|
|
||||||
# P2SH wrapped SegWit address using xpub:
|
# P2SH wrapped SegWit address using xpub:
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--desc', 'sh(wpkh([' + self.fingerprint + '/49h/1h/0h)]' + p2sh_segwit_account_xpub + '/0/0))'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'sh(wpkh([' + self.fingerprint + '/49h/1h/0h]' + p2sh_segwit_account_xpub + '/0/0))'])
|
||||||
|
self.assertNotIn('error', result)
|
||||||
|
self.assertNotIn('code', result)
|
||||||
|
self.assertIn('address', result)
|
||||||
|
|
||||||
# Legacy address
|
# Legacy address
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--desc', 'pkh([' + self.fingerprint + '/44h/1h/0h)]' + legacy_account_xpub + '/0/0)'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'pkh([' + self.fingerprint + '/44h/1h/0h]' + legacy_account_xpub + '/0/0)'])
|
||||||
|
self.assertNotIn('error', result)
|
||||||
|
self.assertNotIn('code', result)
|
||||||
|
self.assertIn('address', result)
|
||||||
|
|
||||||
# Should check xpub
|
# Should check xpub
|
||||||
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h)]' + "not_and_xpub" + '/0/0)'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h]' + "not_and_xpub" + '/0/0)'])
|
||||||
self.assertIn('error', result)
|
self.assertIn('error', result)
|
||||||
self.assertIn('code', result)
|
self.assertIn('code', result)
|
||||||
self.assertEqual(result['code'], -7)
|
self.assertEqual(result['code'], -7)
|
||||||
|
|
||||||
# Should check hex pub
|
# Should check hex pub
|
||||||
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h)]' + "not_and_xpub" + '/0/0)'])
|
result = self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([' + self.fingerprint + '/84h/1h/0h]' + "not_and_xpub" + '/0/0)'])
|
||||||
self.assertIn('error', result)
|
self.assertIn('error', result)
|
||||||
self.assertIn('code', result)
|
self.assertIn('code', result)
|
||||||
self.assertEqual(result['code'], -7)
|
self.assertEqual(result['code'], -7)
|
||||||
|
|
||||||
# Should check fingerprint
|
# Should check fingerprint
|
||||||
self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([00000000/84h/1h/0h)]' + account_xpub + '/0/0)'])
|
self.do_command(self.dev_args + ['displayaddress', '--desc', 'wpkh([00000000/84h/1h/0h]' + account_xpub + '/0/0)'])
|
||||||
self.assertIn('error', result)
|
self.assertIn('error', result)
|
||||||
self.assertIn('code', result)
|
self.assertIn('code', result)
|
||||||
self.assertEqual(result['code'], -7)
|
self.assertEqual(result['code'], -7)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user