mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-15 12:08:59 +00:00
fix(tests): patch over confirm_blob buttonrequest problems
This commit is contained in:
parent
dfac2ae4dd
commit
35be52e31e
@ -65,20 +65,30 @@ async def with_info(
|
||||
info_layout: ui.LayoutObj[Any],
|
||||
br_name: str,
|
||||
br_code: ButtonRequestType,
|
||||
repeat_button_request: bool = False, # TODO this should eventually always be true
|
||||
) -> None:
|
||||
send_button_request = True
|
||||
first_br = br_name
|
||||
next_br = br_name if repeat_button_request else None
|
||||
|
||||
# if repeat_button_request is True:
|
||||
# * `first_br` (br_name) is sent on first interaction
|
||||
# * `next_br` (br_name) is sent on the info screen
|
||||
# * `first_br` is updated to `next_br` (still br_name) and that is sent for every
|
||||
# subsequent interaction
|
||||
# if repeat_button_request is False:
|
||||
# * `first_br` (br_name) is sent on first interaction
|
||||
# * `next_br` (None) is sent on the info screen
|
||||
# * `first_br` is cleared to None for every subsequent interaction
|
||||
while True:
|
||||
result = await interact(
|
||||
main_layout, br_name if send_button_request else None, br_code
|
||||
)
|
||||
result = await interact(main_layout, first_br, br_code)
|
||||
# raises on cancel
|
||||
send_button_request = False
|
||||
|
||||
first_br = next_br
|
||||
|
||||
if result is trezorui2.CONFIRMED:
|
||||
return
|
||||
elif result is trezorui2.INFO:
|
||||
await interact(info_layout, None, raise_on_cancel=None)
|
||||
await interact(info_layout, next_br, br_code, raise_on_cancel=None)
|
||||
continue
|
||||
else:
|
||||
raise RuntimeError # unexpected result
|
||||
|
@ -500,7 +500,9 @@ def confirm_blob_with_optional_pagination(
|
||||
prompt_screen=False,
|
||||
)
|
||||
|
||||
return with_info(main_layout, info_layout, br_name, br_code)
|
||||
return with_info(
|
||||
main_layout, info_layout, br_name, br_code, repeat_button_request=True
|
||||
)
|
||||
|
||||
|
||||
def confirm_blob(
|
||||
|
@ -585,7 +585,9 @@ def confirm_blob_with_optional_pagination(
|
||||
hold=False,
|
||||
chunkify=chunkify,
|
||||
)
|
||||
return with_info(main_layout, info_layout, br_name, br_code)
|
||||
return with_info(
|
||||
main_layout, info_layout, br_name, br_code, repeat_button_request=True
|
||||
)
|
||||
|
||||
|
||||
def confirm_blob(
|
||||
|
@ -351,7 +351,7 @@ class EthereumFlow:
|
||||
self.debug = self.client.debug
|
||||
|
||||
def confirm_data(self, info: bool = False, cancel: bool = False) -> BRGeneratorType:
|
||||
yield
|
||||
assert (yield).name == "confirm_data"
|
||||
TR.assert_equals(self.debug.read_layout().title(), "ethereum__title_input_data")
|
||||
if info:
|
||||
self.debug.press_info()
|
||||
@ -362,8 +362,9 @@ class EthereumFlow:
|
||||
|
||||
def paginate_data(self) -> BRGeneratorType:
|
||||
br = yield
|
||||
TR.assert_equals(self.debug.read_layout().title(), "ethereum__title_input_data")
|
||||
assert br.name == "confirm_data"
|
||||
assert br.pages is not None
|
||||
TR.assert_equals(self.debug.read_layout().title(), "ethereum__title_input_data")
|
||||
for i in range(br.pages):
|
||||
self.debug.read_layout()
|
||||
if i < br.pages - 1:
|
||||
@ -372,9 +373,10 @@ class EthereumFlow:
|
||||
|
||||
def paginate_data_go_back(self) -> BRGeneratorType:
|
||||
br = yield
|
||||
TR.assert_equals(self.debug.read_layout().title(), "ethereum__title_input_data")
|
||||
assert br.name == "confirm_data"
|
||||
assert br.pages is not None
|
||||
assert br.pages > 2
|
||||
TR.assert_equals(self.debug.read_layout().title(), "ethereum__title_input_data")
|
||||
if self.client.layout_type is LayoutType.TR:
|
||||
self.debug.press_right()
|
||||
self.debug.press_right()
|
||||
|
Loading…
Reference in New Issue
Block a user