From 1397c3b4d9e6c95e44a0e6460d02b817f73e8492 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 22 Oct 2018 14:44:36 +0200 Subject: [PATCH] tests: update T1+T2 reset+recovery tests to reflect new Confirm dialog --- .../device_tests/test_msg_recoverydevice_t2.py | 10 ++++++++++ .../tests/device_tests/test_msg_resetdevice.py | 12 ++++++++++++ .../test_msg_resetdevice_nobackup.py | 4 ++++ .../test_msg_resetdevice_skipbackup.py | 8 ++++++++ .../device_tests/test_msg_resetdevice_t2.py | 17 +++++++++++++++++ 5 files changed, 51 insertions(+) diff --git a/trezorlib/tests/device_tests/test_msg_recoverydevice_t2.py b/trezorlib/tests/device_tests/test_msg_recoverydevice_t2.py index b906fe43b..3dba9a3db 100644 --- a/trezorlib/tests/device_tests/test_msg_recoverydevice_t2.py +++ b/trezorlib/tests/device_tests/test_msg_recoverydevice_t2.py @@ -36,6 +36,11 @@ class TestMsgRecoverydeviceT2(TrezorTest): ) ) + # Confirm Recovery + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + # Enter word count assert ret == proto.ButtonRequest( code=proto.ButtonRequestType.MnemonicWordCount @@ -82,6 +87,11 @@ class TestMsgRecoverydeviceT2(TrezorTest): ) ) + # Confirm Recovery + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + # Enter word count assert ret == proto.ButtonRequest( code=proto.ButtonRequestType.MnemonicWordCount diff --git a/trezorlib/tests/device_tests/test_msg_resetdevice.py b/trezorlib/tests/device_tests/test_msg_resetdevice.py index 3026f31e6..217433327 100644 --- a/trezorlib/tests/device_tests/test_msg_resetdevice.py +++ b/trezorlib/tests/device_tests/test_msg_resetdevice.py @@ -41,6 +41,10 @@ class TestMsgResetDevice(TrezorTest): ) ) + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + # Provide entropy assert isinstance(ret, proto.EntropyRequest) internal_entropy = self.client.debug.read_reset_entropy() @@ -110,6 +114,10 @@ class TestMsgResetDevice(TrezorTest): self.client.debug.press_yes() ret = self.client.call_raw(proto.ButtonAck()) + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + assert isinstance(ret, proto.PinMatrixRequest) # Enter PIN for first time @@ -192,6 +200,10 @@ class TestMsgResetDevice(TrezorTest): self.client.debug.press_yes() ret = self.client.call_raw(proto.ButtonAck()) + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + assert isinstance(ret, proto.PinMatrixRequest) # Enter PIN for first time diff --git a/trezorlib/tests/device_tests/test_msg_resetdevice_nobackup.py b/trezorlib/tests/device_tests/test_msg_resetdevice_nobackup.py index bf2f134f2..61b93c57d 100644 --- a/trezorlib/tests/device_tests/test_msg_resetdevice_nobackup.py +++ b/trezorlib/tests/device_tests/test_msg_resetdevice_nobackup.py @@ -38,6 +38,10 @@ class TestMsgResetDeviceNobackup(TrezorTest): ) ) + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + # Provide entropy assert isinstance(ret, proto.EntropyRequest) ret = self.client.call_raw(proto.EntropyAck(entropy=self.external_entropy)) diff --git a/trezorlib/tests/device_tests/test_msg_resetdevice_skipbackup.py b/trezorlib/tests/device_tests/test_msg_resetdevice_skipbackup.py index 2f7c27ea9..7da7858c0 100644 --- a/trezorlib/tests/device_tests/test_msg_resetdevice_skipbackup.py +++ b/trezorlib/tests/device_tests/test_msg_resetdevice_skipbackup.py @@ -42,6 +42,10 @@ class TestMsgResetDeviceSkipbackup(TrezorTest): ) ) + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + # Provide entropy assert isinstance(ret, proto.EntropyRequest) internal_entropy = self.client.debug.read_reset_entropy() @@ -108,6 +112,10 @@ class TestMsgResetDeviceSkipbackup(TrezorTest): ) ) + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + # Provide entropy assert isinstance(ret, proto.EntropyRequest) ret = self.client.call_raw(proto.EntropyAck(entropy=self.external_entropy)) diff --git a/trezorlib/tests/device_tests/test_msg_resetdevice_t2.py b/trezorlib/tests/device_tests/test_msg_resetdevice_t2.py index ba38e4671..e515bb01e 100644 --- a/trezorlib/tests/device_tests/test_msg_resetdevice_t2.py +++ b/trezorlib/tests/device_tests/test_msg_resetdevice_t2.py @@ -35,6 +35,11 @@ class TestMsgResetDeviceT2(TrezorTest): strength = 128 def input_flow(): + # Confirm Reset + btn_code = yield + assert btn_code == B.ResetDevice + self.client.debug.press_yes() + # Backup your seed btn_code = yield assert btn_code == B.ResetDevice @@ -68,6 +73,7 @@ class TestMsgResetDeviceT2(TrezorTest): with mock.patch("os.urandom", os_urandom), self.client: self.client.set_expected_responses( [ + proto.ButtonRequest(code=B.ResetDevice), proto.EntropyRequest(), proto.ButtonRequest(code=B.ResetDevice), proto.ButtonRequest(code=B.ResetDevice), @@ -109,6 +115,11 @@ class TestMsgResetDeviceT2(TrezorTest): strength = 128 def input_flow(): + # Confirm Reset + btn_code = yield + assert btn_code == B.ResetDevice + self.client.debug.press_yes() + # Enter new PIN yield self.client.debug.input("654") @@ -155,6 +166,7 @@ class TestMsgResetDeviceT2(TrezorTest): with mock.patch("os.urandom", os_urandom), self.client: self.client.set_expected_responses( [ + proto.ButtonRequest(code=B.ResetDevice), proto.ButtonRequest(code=B.Other), proto.ButtonRequest(code=B.Other), proto.ButtonRequest(code=B.ResetDevice), @@ -201,6 +213,11 @@ class TestMsgResetDeviceT2(TrezorTest): proto.ResetDevice(strength=strength, pin_protection=True, label="test") ) + # Confirm Reset + assert isinstance(ret, proto.ButtonRequest) + self.client.debug.press_yes() + ret = self.client.call_raw(proto.ButtonAck()) + # Enter PIN for first time assert isinstance(ret, proto.ButtonRequest) self.client.debug.input("654")