diff --git a/hwilib/devices/ledger.py b/hwilib/devices/ledger.py index 7790b18..f64e0fd 100644 --- a/hwilib/devices/ledger.py +++ b/hwilib/devices/ledger.py @@ -309,7 +309,7 @@ class LedgerClient(HardwareWalletClient): raise UnavailableActionError('The Ledger Nano S does not need a PIN sent from the host') # Send pin - def send_pin(self): + def send_pin(self, pin): raise UnavailableActionError('The Ledger Nano S does not need a PIN sent from the host') def enumerate(password=''): diff --git a/test/test_ledger.py b/test/test_ledger.py index c636f32..06445da 100755 --- a/test/test_ledger.py +++ b/test/test_ledger.py @@ -10,7 +10,7 @@ import time import unittest from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from test_device import DeviceTestCase, start_bitcoind, TestDeviceConnect, TestDisplayAddress, TestGetKeypool, TestSignTx +from test_device import DeviceTestCase, start_bitcoind, TestDeviceConnect, TestDisplayAddress, TestGetKeypool, TestSignMessage, TestSignTx from hwilib.cli import process_commands @@ -28,12 +28,57 @@ def ledger_test_suite(rpc, userpass): break assert(path is not None and master_xpub is not None and fingerprint is not None) + # Ledger specific disabled command tests + class TestLedgerDisabledCommands(DeviceTestCase): + def test_pin(self): + result = process_commands(self.dev_args + ['promptpin']) + self.assertIn('error', result) + self.assertIn('code', result) + self.assertEqual(result['error'], 'The Ledger Nano S does not need a PIN sent from the host') + self.assertEqual(result['code'], -9) + + result = process_commands(self.dev_args + ['sendpin', '1234']) + self.assertIn('error', result) + self.assertIn('code', result) + self.assertEqual(result['error'], 'The Ledger Nano S does not need a PIN sent from the host') + self.assertEqual(result['code'], -9) + + def test_setup(self): + result = process_commands(self.dev_args + ['setup']) + self.assertIn('error', result) + self.assertIn('code', result) + self.assertEqual(result['error'], 'The Ledger Nano S does not support software setup') + self.assertEqual(result['code'], -9) + + def test_wipe(self): + result = process_commands(self.dev_args + ['wipe']) + self.assertIn('error', result) + self.assertIn('code', result) + self.assertEqual(result['error'], 'The Ledger Nano S does not support wiping via software') + self.assertEqual(result['code'], -9) + + def test_restore(self): + result = process_commands(self.dev_args + ['restore']) + self.assertIn('error', result) + self.assertIn('code', result) + self.assertEqual(result['error'], 'The Ledger Nano S does not support restoring via software') + self.assertEqual(result['code'], -9) + + def test_backup(self): + result = process_commands(self.dev_args + ['backup']) + self.assertIn('error', result) + self.assertIn('code', result) + self.assertEqual(result['error'], 'The Ledger Nano S does not support creating a backup via software') + self.assertEqual(result['code'], -9) + # Generic Device tests suite = unittest.TestSuite() + suite.addTest(DeviceTestCase.parameterize(TestLedgerDisabledCommands, rpc, userpass, 'ledger', path, fingerprint, master_xpub)) suite.addTest(DeviceTestCase.parameterize(TestDeviceConnect, rpc, userpass, 'ledger', path, fingerprint, master_xpub)) suite.addTest(DeviceTestCase.parameterize(TestGetKeypool, rpc, userpass, 'ledger', path, fingerprint, master_xpub)) suite.addTest(DeviceTestCase.parameterize(TestSignTx, rpc, userpass, 'ledger', path, fingerprint, master_xpub)) suite.addTest(DeviceTestCase.parameterize(TestDisplayAddress, rpc, userpass, 'ledger', path, fingerprint, master_xpub)) + suite.addTest(DeviceTestCase.parameterize(TestSignMessage, rpc, userpass, 'ledger', path, fingerprint, master_xpub)) return suite if __name__ == '__main__':