diff --git a/tests/test.py b/tests/test.py index 788870500..5882154f3 100755 --- a/tests/test.py +++ b/tests/test.py @@ -20,8 +20,8 @@ TODO: x iny cointype ako 0 - chceme v tomto release(?) - * SignMessage workflow - * VerifyMessage workflow + x SignMessage workflow + x VerifyMessage workflow * otestovat session handling (tento test bude zrejme failovat na RPi) * Failure_NotInitialized @@ -31,4 +31,6 @@ TODO: * Client requires PIN x Zero signature test + +* test bip39, utf, passphrase ''' diff --git a/tests/test_entropy.py b/tests/test_entropy.py index 407c33d23..4183d63ea 100644 --- a/tests/test_entropy.py +++ b/tests/test_entropy.py @@ -2,8 +2,6 @@ import unittest import common import math -from trezorlib import messages_pb2 as messages - def entropy(data): counts = {} for c in data: @@ -12,7 +10,7 @@ def entropy(data): else: counts[c] = 1 e = 0 - for k,v in counts.iteritems(): + for _, v in counts.iteritems(): p = 1.0 * v / len(data) e -= p * math.log(p, 256) return e diff --git a/tests/test_protect_call.py b/tests/test_protect_call.py index 1a2324b61..fa28ada93 100644 --- a/tests/test_protect_call.py +++ b/tests/test_protect_call.py @@ -4,7 +4,7 @@ import common from trezorlib import messages_pb2 as proto from trezorlib import types_pb2 as types -from trezorlib.client import PinException +from trezorlib.client import PinException, CallException # FIXME TODO Add passphrase tests @@ -17,6 +17,37 @@ class TestProtectCall(common.TrezorTest): passphrase_protection=passphrase) self.assertEqual(res, 'random data') + def test_expected_responses(self): + # This is low-level test of set_expected_responses() + # feature of debugging client + + # Scenario 1 - Received unexpected message + self.client.set_expected_responses([]) + self.assertRaises(CallException, self._some_protected_call, True, True, True) + + # Scenario 2 - Received other than expected message + self.client.set_expected_responses([proto.Success()]) + self.assertRaises(CallException, self._some_protected_call, True, True, True) + + # Scenario 3 - Not received expected message + self.client.set_expected_responses([proto.ButtonRequest(), + proto.Success(), + proto.Success()]) # This is expected, but not received + self.assertRaises(Exception, self._some_protected_call, True, False, False) + + # Scenario 4 - Received what expected + self.client.set_expected_responses([proto.ButtonRequest(), + proto.PinMatrixRequest(), + # proto.PassphraseRequest(), # passhrase is already in session + proto.Success(message='random data')]) + self._some_protected_call(True, True, True) + + # Scenario 5 - Failed message by field filter + self.client.set_expected_responses([proto.ButtonRequest(), + proto.PinMatrixRequest(), + proto.Success(message='wrong data')]) + self.assertRaises(CallException, self._some_protected_call, True, True, True) + def test_no_protection(self): self.client.wipe_device() self.client.load_device_by_mnemonic( @@ -28,7 +59,7 @@ class TestProtectCall(common.TrezorTest): ) self.assertEqual(self.client.debug.read_pin()[0], '') - self.client.set_expected_buttonrequests([]) + self.client.set_expected_responses([proto.Success()]) self._some_protected_call(False, True, True) def test_pin(self): @@ -41,7 +72,9 @@ class TestProtectCall(common.TrezorTest): self.assertEqual(self.client.debug.read_pin()[0], self.pin2) self.client.setup_debuglink(button=True, pin_correct=True) - self.client.set_expected_buttonrequests([types.ButtonRequest_Other]) + self.client.set_expected_responses([proto.ButtonRequest(), + proto.PinMatrixRequest(), + proto.Success()]) self._some_protected_call(True, True, False) def test_incorrect_pin(self): @@ -67,8 +100,7 @@ class TestProtectCall(common.TrezorTest): start = time.time() self.assertRaises(PinException, self._some_protected_call, False, True, False) test_backoff(attempt, start) - - ''' +''' # Unplug Trezor now self.client.debuglink.stop() self.client.close() diff --git a/tests/test_signtx.py b/tests/test_signtx.py index fc8ec5ca8..660775b04 100644 --- a/tests/test_signtx.py +++ b/tests/test_signtx.py @@ -54,8 +54,8 @@ class TestSignTx(common.TrezorTest): ) msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, ], [out1, ]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput] - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.TxRequest(request_index=-1)]) tx = self.client.call(msg) # Accepted by network: tx fd79435246dee76b2f159d2db08032d666c95adc544de64c8c49f474df4a7fee @@ -82,8 +82,9 @@ class TestSignTx(common.TrezorTest): self.client.set_tx_func(FakeTestnetBlockchain().get_tx) msg = self.client._prepare_simple_sign_tx('Testnet', [inp1, ], [out1, out2]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput] * 2 - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.TxRequest()]) tx = self.client.call(msg) self.assertEqual(binascii.hexlify(tx.serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006b4830450221009c2d30385519fdb13dce13d5ac038be07d7b2dad0b0f7b2c1c339d7255bcf553022056a2f5bceab3cd0ffed4d388387e631f419d67ff9ce7798e3d7dfe6a6d6ec4bd0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0280ce341d000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000') @@ -109,10 +110,10 @@ class TestSignTx(common.TrezorTest): self.client.set_tx_func(FakeTestnetBlockchain().get_tx) msg = self.client._prepare_simple_sign_tx('Testnet', [inp1, ], [out1, out2]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput, - proto_types.ButtonRequest_ConfirmOutput, - proto_types.ButtonRequest_FeeOverThreshold] - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_FeeOverThreshold), + proto.TxRequest()]) tx = self.client.call(msg) self.assertEqual(binascii.hexlify(tx.serialized_tx), '0100000001549d2977998f899a63c0a9da30dedb2841e33fef561097b05822eccbc7f3906f010000006b483045022100d74e9fa5c7ff5966d52bce8d1d772c1e3ef1376395fb85a0bbf910e723bd606d02204cb8df6debd7c4c076632011bb1e180495bcf3630d2471c354bed56c2e45a2180121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0200389c1c000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac0065cd1d000000001976a9142db345c36563122e2fd0f5485fb7ea9bbf7cb5a288ac00000000') @@ -138,8 +139,9 @@ class TestSignTx(common.TrezorTest): ) msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, ], [out1, out2]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput] * 2 - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.TxRequest()]) tx = self.client.call(msg) self.assertEqual(binascii.hexlify(tx.serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100c1400d8485d3bdcae7413e123148f35ece84806fc387ab88c66b469df89aef1702201d481d04216b319dc549ffe2333143629ba18828a4e2d1783ab719a6aa263eb70121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff02e0930400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000') @@ -170,8 +172,10 @@ class TestSignTx(common.TrezorTest): ) msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, ], [out1, out2, out3]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput] * 3 - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.TxRequest()]) tx = self.client.call(msg) self.assertEqual(binascii.hexlify(tx.serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100e695e2c530c7c0fc32e6b79b7cff56a7f70a8c9da787534f46b4204070f914fc02207b0879a81408a11e23b11d4c7965c62b5fc6d5c2d92340f5ee2da7b40e99314a0121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0300650400000000001976a914de9b2a8da088824e8fe51debea566617d851537888ace02e0000000000001976a9141fe1d337fb81afca42818051e12fd18245d1b17288ac80380100000000001976a9140223b1a09138753c9cb0baf95a0a62c82711567a88ac00000000') @@ -205,8 +209,9 @@ class TestSignTx(common.TrezorTest): ) msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, inp2], [out1, out2]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput] * 2 - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.TxRequest()]) tx = self.client.call(msg) # Accepted by network: tx c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb @@ -242,8 +247,8 @@ class TestSignTx(common.TrezorTest): outputs.append(out) msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, inp2], outputs) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput] * 255 - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), ] * 255 + \ + [proto.TxRequest(), ]) tx = self.client.call(msg) self.assertEqual(binascii.hexlify(tx.serialized_tx), '0100000002fb792f470a58993e14964c9bd46cdf37cb4bbc3f61540cb651580c82ed243ec6010000006b483045022100969da46f94a81f34f3717b014e0c3e1826eda1b0022ec2f9ce39f3d750ab9235022026da269770993211a1503413566a339bbb4389a482fffcf8e1f76713fc3b94f5012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902ffffffffe56582d2119100cb1d3da8232291e053f71e25fb669c87b32a667749959ea239010000006a473044022052e1419bb237b9db400ab5e3df16db6355619d545fde9030924a360763ae9ad40220704beab04d72ecaeb42eca7d98faca7a0941e65f2e1341f183be2b83e6b09e1c012103477b9f0f34ae85434ce795f0c5e1e90c9420e5b5fad084d7cce9a487b94a7902fffffffffdff00d8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088acd8270000000000001976a914f0a2b64e56ee2ff57126232f84af6e3a41d4055088ac00000000') @@ -265,9 +270,9 @@ class TestSignTx(common.TrezorTest): ) msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, ], [out1, ]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput, - proto_types.ButtonRequest_FeeOverThreshold] - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.ButtonRequest(code=proto_types.ButtonRequest_FeeOverThreshold), + proto.TxRequest()]) tx = self.client.call(msg) self.assertEqual(binascii.hexlify(tx.serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006a4730440220361b8268718533055682f4532d30c553ce778f70b217457a9aa1956e457c5aac0220538ae285bb340484bb09a67635d29192a14e61d8a8385b8b090a92e3e97e1c010121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0120300500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000') @@ -288,8 +293,9 @@ class TestSignTx(common.TrezorTest): ) msg = self.client._prepare_simple_sign_tx('Bitcoin', [inp1, ], [out1, ]) - expected_btn = [proto_types.ButtonRequest_ConfirmOutput] - self.client.set_expected_buttonrequests(expected_btn) + self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ConfirmOutput), + proto.Failure(code=proto_types.Failure_NotEnoughFunds)]) + try: self.client.call(msg) except CallException as e: