feat(python/debuglink): detect input flows that continue past end of test

should make input flows a tiny bit more robust still
matejcik/global-layout-only2
matejcik 3 months ago
parent 432643be5a
commit d2e8d8d5b2

@ -1090,6 +1090,14 @@ class TrezorClientDebugLink(TrezorClient):
# If no other exception was raised, evaluate missed responses
# (raises AssertionError on mismatch)
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):
# 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
def input_flow_silent():
yield
# It will never reach this - there is just loader on the screen
assert False
# 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
# Device is loaded with seed, language change is shown on the screen
with client:

@ -92,8 +92,10 @@ class InputFlowSetupDevicePINWIpeCode(InputFlowBase):
self.debug.press_yes()
if self.debug.model == "Safe 3":
yield from swipe_if_necessary(self.debug) # wipe code info
self.debug.press_yes()
layout = self.debug.read_layout()
if not "PinKeyboard" in layout.all_components():
yield from swipe_if_necessary(self.debug) # wipe code info
self.debug.press_yes()
yield # enter current pin
self.debug.input(self.pin)
@ -121,8 +123,10 @@ class InputFlowNewCodeMismatch(InputFlowBase):
self.debug.press_yes()
if self.debug.model == "Safe 3":
yield from swipe_if_necessary(self.debug) # code info
self.debug.press_yes()
layout = self.debug.read_layout()
if not "PinKeyboard" in layout.all_components():
yield from swipe_if_necessary(self.debug) # code info
self.debug.press_yes()
def input_two_different_pins() -> BRGeneratorType:
yield from self.PIN.setup_new_pin(self.first_code, self.second_code)

@ -20,9 +20,10 @@ class PinFlow:
self.debug.input(pin)
if self.debug.model == "Safe 3":
yield # Reenter PIN
TR.assert_in(
self.debug.read_layout().text_content(), "pin__reenter_to_confirm"
)
# todo update for wipe code
# TR.assert_in(
# self.debug.read_layout().text_content(), "pin__reenter_to_confirm"
# )
self.debug.press_yes()
yield # Enter PIN again
assert "PinKeyboard" in self.debug.read_layout().all_components()
@ -411,7 +412,6 @@ class EthereumFlow:
)
self.debug.press_no()
self.debug.press_yes()
yield
else:
# confirm intro
if info:
@ -440,4 +440,3 @@ class EthereumFlow:
self.debug.press_left()
self.debug.press_left()
self.debug.press_middle()
yield

Loading…
Cancel
Save