mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-16 11:38:12 +00:00
WIP - fixing tests
This commit is contained in:
parent
7248d4192b
commit
ab784ed6ff
@ -92,7 +92,7 @@ where
|
||||
{
|
||||
fn trace(&self, t: &mut dyn crate::trace::Tracer) {
|
||||
t.open("Frame");
|
||||
t.title(&self.title.inner().text().as_ref());
|
||||
t.title(self.title.inner().text().as_ref());
|
||||
t.field("content", &self.content);
|
||||
t.close();
|
||||
}
|
||||
@ -186,7 +186,7 @@ where
|
||||
{
|
||||
fn trace(&self, t: &mut dyn crate::trace::Tracer) {
|
||||
t.open("NotificationFrame");
|
||||
t.title(&self.title.as_ref());
|
||||
t.title(self.title.as_ref());
|
||||
t.field("content", &self.content);
|
||||
t.close();
|
||||
}
|
||||
|
@ -182,7 +182,6 @@ class LayoutButtons(LayoutBase):
|
||||
|
||||
Only for TT.
|
||||
"""
|
||||
print("self.str_content", self.str_content)
|
||||
return re.findall(r"< Button +text : +(.*?) +>", self.str_content)
|
||||
|
||||
|
||||
@ -210,7 +209,6 @@ class LayoutContent(LayoutBase):
|
||||
********************
|
||||
Icon:cancel [Cancel], --- [None], CONFIRM [Confirm]
|
||||
"""
|
||||
print(self.str_content)
|
||||
title_separator = f"\n{20*'-'}\n"
|
||||
btn_separator = f"\n{20*'*'}\n"
|
||||
|
||||
|
@ -35,8 +35,13 @@ def select_number_of_words(
|
||||
layout = debug.read_layout()
|
||||
|
||||
# select number of words
|
||||
assert "select the number of words" in layout.text_content()
|
||||
if legacy_ui:
|
||||
assert "Select number of words" in layout.str_content
|
||||
else:
|
||||
assert "select the number of words" in layout.text_content()
|
||||
|
||||
layout = debug.click(buttons.OK, wait=True)
|
||||
|
||||
if legacy_ui:
|
||||
assert layout.str_content == "WordSelector"
|
||||
else:
|
||||
@ -51,7 +56,11 @@ def select_number_of_words(
|
||||
) # raises if num of words is invalid
|
||||
coords = buttons.grid34(index % 3, index // 3)
|
||||
layout = debug.click(coords, wait=True)
|
||||
assert "Enter any share" in layout.text_content()
|
||||
|
||||
if legacy_ui:
|
||||
assert "Enter any share" in layout.str_content
|
||||
else:
|
||||
assert "Enter any share" in layout.text_content()
|
||||
|
||||
|
||||
def enter_share(
|
||||
|
@ -85,6 +85,7 @@ def _process_tested(fixture_test_path: Path, test_name: str) -> None:
|
||||
|
||||
expected_hash = FILE_HASHES.get(test_name)
|
||||
if expected_hash is None:
|
||||
_write_diff_to_file(test_name, actual_hash)
|
||||
pytest.fail(f"Hash of {test_name} not found in fixtures.json")
|
||||
|
||||
if actual_hash != expected_hash:
|
||||
@ -93,15 +94,7 @@ def _process_tested(fixture_test_path: Path, test_name: str) -> None:
|
||||
fixture_test_path, test_name, actual_hash, expected_hash
|
||||
)
|
||||
|
||||
# Writing the diff to a file, so that we can process it later
|
||||
# Appending a new JSON object, not having to regenerate the
|
||||
# whole file (which could cause issues with multiple processes/threads)
|
||||
with open(FIXTURES_DIFF, "a") as f:
|
||||
diff = {
|
||||
"test_name": test_name,
|
||||
"actual_hash": actual_hash,
|
||||
}
|
||||
f.write(json.dumps(diff) + "\n")
|
||||
_write_diff_to_file(test_name, actual_hash)
|
||||
|
||||
pytest.fail(
|
||||
f"Hash of {test_name} differs.\n"
|
||||
@ -113,6 +106,18 @@ def _process_tested(fixture_test_path: Path, test_name: str) -> None:
|
||||
testreport.passed(fixture_test_path, test_name, actual_hash)
|
||||
|
||||
|
||||
def _write_diff_to_file(test_name: str, actual_hash: str) -> None:
|
||||
"""Writing the diff to a file, so that we can process it later"""
|
||||
# Appending a new JSON object, not having to regenerate the
|
||||
# whole file (which could cause issues with multiple processes/threads)
|
||||
with open(FIXTURES_DIFF, "a") as f:
|
||||
diff = {
|
||||
"test_name": test_name,
|
||||
"actual_hash": actual_hash,
|
||||
}
|
||||
f.write(json.dumps(diff) + "\n")
|
||||
|
||||
|
||||
def get_last_call_test_result(request: pytest.FixtureRequest) -> Optional[bool]:
|
||||
# if test did not finish, e.g. interrupted by Ctrl+C, the pytest_runtest_makereport
|
||||
# did not create the attribute we need
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -331,11 +331,11 @@ def test_upgrade_shamir_recovery(gen: str, tag: Optional[str]):
|
||||
|
||||
# second share
|
||||
layout = recovery.enter_share(debug, MNEMONIC_SLIP39_BASIC_20_3of6[2])
|
||||
assert "1 more share" in layout.str_content
|
||||
assert "1 more share" in layout.text_content()
|
||||
|
||||
# last one
|
||||
layout = recovery.enter_share(debug, MNEMONIC_SLIP39_BASIC_20_3of6[1])
|
||||
assert "You have successfully" in layout.str_content
|
||||
assert "You have finished recovering your wallet" in layout.text_content()
|
||||
|
||||
# Check the result
|
||||
state = debug.state()
|
||||
|
Loading…
Reference in New Issue
Block a user