mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-07 15:18:08 +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
e19a58fb6e
commit
3327de6d02
@ -1120,6 +1120,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
|
||||||
|
@ -99,6 +99,8 @@ class InputFlowSetupDevicePINWIpeCode(InputFlowBase):
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
if self.model() is models.T2B1:
|
if self.model() is models.T2B1:
|
||||||
|
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()
|
||||||
|
|
||||||
@ -128,6 +130,8 @@ class InputFlowNewCodeMismatch(InputFlowBase):
|
|||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
|
|
||||||
if self.model() is models.T2B1:
|
if self.model() is models.T2B1:
|
||||||
|
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()
|
||||||
|
|
||||||
@ -711,8 +715,6 @@ class InputFlowPaymentRequestDetails(InputFlowBase):
|
|||||||
|
|
||||||
yield # confirm transaction
|
yield # confirm transaction
|
||||||
self.debug.press_yes()
|
self.debug.press_yes()
|
||||||
yield # confirm transaction
|
|
||||||
self.debug.press_yes()
|
|
||||||
|
|
||||||
def input_flow_t3t1(self) -> BRGeneratorType:
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
||||||
yield # request to see details
|
yield # request to see details
|
||||||
@ -1065,9 +1067,6 @@ def lock_time_input_flow_tt(
|
|||||||
|
|
||||||
yield # confirm transaction
|
yield # confirm transaction
|
||||||
debug.press_yes()
|
debug.press_yes()
|
||||||
if double_confirm:
|
|
||||||
yield # confirm transaction
|
|
||||||
debug.press_yes()
|
|
||||||
|
|
||||||
|
|
||||||
def lock_time_input_flow_tr(
|
def lock_time_input_flow_tr(
|
||||||
@ -1124,17 +1123,13 @@ class InputFlowLockTimeBlockHeight(InputFlowBase):
|
|||||||
assert self.block_height in layout_text
|
assert self.block_height in layout_text
|
||||||
|
|
||||||
def input_flow_tt(self) -> BRGeneratorType:
|
def input_flow_tt(self) -> BRGeneratorType:
|
||||||
yield from lock_time_input_flow_tt(
|
yield from lock_time_input_flow_tt(self.debug, self.assert_func)
|
||||||
self.debug, self.assert_func, double_confirm=True
|
|
||||||
)
|
|
||||||
|
|
||||||
def input_flow_tr(self) -> BRGeneratorType:
|
def input_flow_tr(self) -> BRGeneratorType:
|
||||||
yield from lock_time_input_flow_tr(self.debug, self.assert_func)
|
yield from lock_time_input_flow_tr(self.debug, self.assert_func)
|
||||||
|
|
||||||
def input_flow_t3t1(self) -> BRGeneratorType:
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
||||||
yield from lock_time_input_flow_t3t1(
|
yield from lock_time_input_flow_t3t1(self.debug, self.assert_func)
|
||||||
self.debug, self.assert_func, double_confirm=True
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InputFlowLockTimeDatetime(InputFlowBase):
|
class InputFlowLockTimeDatetime(InputFlowBase):
|
||||||
|
@ -23,9 +23,10 @@ class PinFlow:
|
|||||||
self.debug.input(pin)
|
self.debug.input(pin)
|
||||||
if self.client.model is models.T2B1:
|
if self.client.model is models.T2B1:
|
||||||
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()
|
||||||
@ -490,7 +491,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:
|
||||||
@ -519,4 +519,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