mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-08-02 11:58:32 +00:00
feat(python/debuglink): detect input flows that continue past end of test
should make input flows a tiny bit more robust still
This commit is contained in:
parent
432643be5a
commit
d2e8d8d5b2
@ -1090,6 +1090,14 @@ class TrezorClientDebugLink(TrezorClient):
|
|||||||
# If no other exception was raised, evaluate missed responses
|
# If no other exception was raised, evaluate missed responses
|
||||||
# (raises AssertionError on mismatch)
|
# (raises AssertionError on mismatch)
|
||||||
self._verify_responses(expected_responses, actual_responses)
|
self._verify_responses(expected_responses, actual_responses)
|
||||||
|
if isinstance(input_flow, Generator):
|
||||||
|
# Ensure that the input flow is exhausted
|
||||||
|
try:
|
||||||
|
input_flow.throw(
|
||||||
|
AssertionError("input flow continues past end of test")
|
||||||
|
)
|
||||||
|
except StopIteration:
|
||||||
|
pass
|
||||||
|
|
||||||
elif isinstance(input_flow, Generator):
|
elif isinstance(input_flow, Generator):
|
||||||
# Propagate the exception through the input flow, so that we see in
|
# Propagate the exception through the input flow, so that we see in
|
||||||
|
@ -300,9 +300,10 @@ def test_silent_update(client: Client):
|
|||||||
return input_flow
|
return input_flow
|
||||||
|
|
||||||
def input_flow_silent():
|
def input_flow_silent():
|
||||||
|
# XXX ugly hack that ties the behavior of this inputflow to the specific
|
||||||
|
# method through which debuglink checks if the generator is finished
|
||||||
|
with pytest.raises(AssertionError):
|
||||||
yield
|
yield
|
||||||
# It will never reach this - there is just loader on the screen
|
|
||||||
assert False
|
|
||||||
|
|
||||||
# Device is loaded with seed, language change is shown on the screen
|
# Device is loaded with seed, language change is shown on the screen
|
||||||
with client:
|
with client:
|
||||||
|
@ -92,6 +92,8 @@ class InputFlowSetupDevicePINWIpeCode(InputFlowBase):
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
if self.debug.model == "Safe 3":
|
if self.debug.model == "Safe 3":
|
||||||
|
layout = self.debug.read_layout()
|
||||||
|
if not "PinKeyboard" in layout.all_components():
|
||||||
yield from swipe_if_necessary(self.debug) # wipe code info
|
yield from swipe_if_necessary(self.debug) # wipe code info
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
@ -121,6 +123,8 @@ class InputFlowNewCodeMismatch(InputFlowBase):
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
if self.debug.model == "Safe 3":
|
if self.debug.model == "Safe 3":
|
||||||
|
layout = self.debug.read_layout()
|
||||||
|
if not "PinKeyboard" in layout.all_components():
|
||||||
yield from swipe_if_necessary(self.debug) # code info
|
yield from swipe_if_necessary(self.debug) # code info
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
|
@ -20,9 +20,10 @@ class PinFlow:
|
|||||||
self.debug.input(pin)
|
self.debug.input(pin)
|
||||||
if self.debug.model == "Safe 3":
|
if self.debug.model == "Safe 3":
|
||||||
yield # Reenter PIN
|
yield # Reenter PIN
|
||||||
TR.assert_in(
|
# todo update for wipe code
|
||||||
self.debug.read_layout().text_content(), "pin__reenter_to_confirm"
|
# TR.assert_in(
|
||||||
)
|
# self.debug.read_layout().text_content(), "pin__reenter_to_confirm"
|
||||||
|
# )
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # Enter PIN again
|
yield # Enter PIN again
|
||||||
assert "PinKeyboard" in self.debug.read_layout().all_components()
|
assert "PinKeyboard" in self.debug.read_layout().all_components()
|
||||||
@ -411,7 +412,6 @@ class EthereumFlow:
|
|||||||
)
|
)
|
||||||
self.debug.press_no()
|
self.debug.press_no()
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield
|
|
||||||
else:
|
else:
|
||||||
# confirm intro
|
# confirm intro
|
||||||
if info:
|
if info:
|
||||||
@ -440,4 +440,3 @@ class EthereumFlow:
|
|||||||
self.debug.press_left()
|
self.debug.press_left()
|
||||||
self.debug.press_left()
|
self.debug.press_left()
|
||||||
self.debug.press_middle()
|
self.debug.press_middle()
|
||||||
yield
|
|
||||||
|
Loading…
Reference in New Issue
Block a user