Digital Bitbox manual tests
This commit is contained in:
parent
a834e13e18
commit
41d3faedfd
@ -11,6 +11,7 @@ from test_device import start_bitcoind
|
||||
from test_psbt import TestPSBT
|
||||
from test_trezor import trezor_test_suite
|
||||
from test_ledger import ledger_test_suite
|
||||
from test_digitalbitbox import digitalbitbox_test_suite
|
||||
|
||||
parser = argparse.ArgumentParser(description='Setup the testing environment and run automated tests')
|
||||
trezor_group = parser.add_mutually_exclusive_group()
|
||||
@ -22,6 +23,7 @@ coldcard_group.add_argument('--coldcard', help='Path to Coldcard simulator.', de
|
||||
ledger_group = parser.add_mutually_exclusive_group()
|
||||
ledger_group.add_argument('--ledger', help='Run physical Ledger Nano S/X tests.', action='store_true')
|
||||
|
||||
parser.add_argument('--digitalbitbox', help='Run physical Digital Bitbox tests.', action='store_true')
|
||||
parser.add_argument('--bitcoind', help='Path to bitcoind.', default='work/bitcoin/src/bitcoind')
|
||||
parser.add_argument('--password', '-p', help='Device password')
|
||||
args = parser.parse_args()
|
||||
@ -31,7 +33,7 @@ suite = unittest.TestSuite()
|
||||
suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(TestSegwitAddress))
|
||||
suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(TestPSBT))
|
||||
|
||||
if not args.no_trezor or not args.no_coldcard or args.ledger:
|
||||
if not args.no_trezor or not args.no_coldcard or args.ledger or args.digitalbitbox:
|
||||
# Start bitcoind
|
||||
rpc, userpass = start_bitcoind(args.bitcoind)
|
||||
|
||||
@ -41,5 +43,10 @@ if not args.no_coldcard:
|
||||
suite.addTest(coldcard_test_suite(args.coldcard, rpc, userpass))
|
||||
if args.ledger:
|
||||
suite.addTest(ledger_test_suite(rpc, userpass))
|
||||
if args.digitalbitbox:
|
||||
if args.password:
|
||||
suite.addTest(digitalbitbox_test_suite(rpc, userpass, args.password))
|
||||
else:
|
||||
print('Cannot run Digital Bitbox test without --password set')
|
||||
result = unittest.TextTestRunner().run(suite)
|
||||
sys.exit(not result.wasSuccessful())
|
||||
|
||||
@ -276,8 +276,8 @@ class TestSignTx(DeviceTestCase):
|
||||
|
||||
# Test wrapper to avoid mixed-inputs signing for Ledger
|
||||
def test_signtx(self):
|
||||
supports_mixed = {'coldcard', 'trezor'}
|
||||
supports_multisig = {'ledger', 'trezor'}
|
||||
supports_mixed = {'coldcard', 'trezor', 'digitalbitbox'}
|
||||
supports_multisig = {'ledger', 'trezor', 'digitalbitbox'}
|
||||
if self.type not in supports_mixed:
|
||||
self._test_signtx("legacy", self.type in supports_multisig)
|
||||
self._test_signtx("segwit", self.type in supports_multisig)
|
||||
|
||||
42
test/test_digitalbitbox.py
Executable file
42
test/test_digitalbitbox.py
Executable file
@ -0,0 +1,42 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import unittest
|
||||
|
||||
from test_device import DeviceTestCase, start_bitcoind, TestDeviceConnect, TestGetKeypool, TestSignTx, TestSignMessage
|
||||
|
||||
from hwilib.commands import process_commands
|
||||
|
||||
def digitalbitbox_test_suite(rpc, userpass, password):
|
||||
# Look for real Digital BitBox using HWI API(self-referential, but no other way)
|
||||
enum_res = process_commands(['-p', password, 'enumerate'])
|
||||
path = None
|
||||
master_xpub = None
|
||||
fingerprint = None
|
||||
for device in enum_res:
|
||||
if device['type'] == 'digitalbitbox':
|
||||
fingerprint = device['fingerprint']
|
||||
path = device['path']
|
||||
master_xpub = process_commands(['-f', fingerprint, '-p', password, 'getmasterxpub'])['xpub']
|
||||
break
|
||||
assert(path is not None and master_xpub is not None and fingerprint is not None)
|
||||
|
||||
# Generic Device tests
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(DeviceTestCase.parameterize(TestDeviceConnect, rpc, userpass, 'digitalbitbox', path, fingerprint, master_xpub, password))
|
||||
suite.addTest(DeviceTestCase.parameterize(TestGetKeypool, rpc, userpass, 'digitalbitbox', path, fingerprint, master_xpub, password))
|
||||
suite.addTest(DeviceTestCase.parameterize(TestSignTx, rpc, userpass, 'digitalbitbox', path, fingerprint, master_xpub, password))
|
||||
suite.addTest(DeviceTestCase.parameterize(TestSignMessage, rpc, userpass, 'digitalbitbox', path, fingerprint, master_xpub, password))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Test Digital Bitbox implementation')
|
||||
parser.add_argument('bitcoind', help='Path to bitcoind binary')
|
||||
parser.add_argument('password', help='Device password')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Start bitcoind
|
||||
rpc, userpass = start_bitcoind(args.bitcoind)
|
||||
|
||||
suite = digitalbitbox_test_suite(rpc, userpass, args.password)
|
||||
unittest.TextTestRunner().run(suite)
|
||||
Loading…
Reference in New Issue
Block a user