Skip to content

Commit

Permalink
Merge pull request #249 from trilitech/palmer@functori@stax-tests-update
Browse files Browse the repository at this point in the history
Stax tests update
  • Loading branch information
spalmer25 authored Jul 16, 2024
2 parents 5b34ffe + f07f1b2 commit e624d29
Show file tree
Hide file tree
Showing 157 changed files with 424 additions and 394 deletions.
15 changes: 8 additions & 7 deletions app/src/ui_stream_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ blindsign_splash(void)
{
TZ_PREAMBLE(("void"));
nbgl_useCaseReviewStart(
&C_round_warning_64px, "Blind signing",
&C_Important_Circle_64px, "Blind signing",
"This transaction can not be securely interpreted by Ledger Stax. It "
"might put your assets at risk.",
"Reject transaction", start_blindsign, tz_reject_ui);
Expand Down Expand Up @@ -127,11 +127,12 @@ switch_to_blindsigning(__attribute__((unused)) const char *err_type,
global.keys.apdu.sign.step = SIGN_ST_WAIT_USER_INPUT;
global.step = ST_BLIND_SIGN;
if (N_settings.blindsigning) {
nbgl_useCaseReviewStart(
&C_round_warning_64px, "Blind signing required:\nParsing Error",
err_code, "Reject transaction", blindsign_splash, tz_reject_ui);
nbgl_useCaseReviewStart(&C_Important_Circle_64px,
"Blind signing required:\nParsing Error",
err_code, "Reject transaction",
blindsign_splash, tz_reject_ui);
} else {
nbgl_useCaseChoice(&C_round_warning_64px,
nbgl_useCaseChoice(&C_Important_Circle_64px,
"Enable blind signing to authorize this "
"transaction:\nParsing Error",
err_code, "Enable blind signing",
Expand All @@ -145,7 +146,7 @@ expert_mode_splash(void)
{
TZ_PREAMBLE(("void"));

nbgl_useCaseReviewStart(&C_round_warning_64px, "Expert mode",
nbgl_useCaseReviewStart(&C_Important_Circle_64px, "Expert mode",
"Next screen requires careful review",
"Reject transaction", tz_ui_stream_start,
tz_reject_ui);
Expand Down Expand Up @@ -175,7 +176,7 @@ tz_enable_expert_mode_ui(void)
{
FUNC_LEAVE();

nbgl_useCaseChoice(&C_round_warning_64px,
nbgl_useCaseChoice(&C_Important_Circle_64px,
"Enable expert mode to authorize this "
"transaction",
"", "Enable expert mode", "Reject transaction",
Expand Down
Binary file modified tests/integration/stax/snapshots/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/integration/stax/snapshots/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/integration/stax/snapshots/test_basic/settings_expert_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified tests/integration/stax/snapshots/test_parsing_errors/too_deep.png
Binary file modified tests/integration/stax/snapshots/test_parsing_errors/too_large.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
32 changes: 15 additions & 17 deletions tests/integration/stax/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,27 @@
if __name__ == "__main__":
app = stax_app(__file__)

app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

app.welcome.info()
app.assert_screen("settings_blindsigning_off")
app.welcome.settings()
app.assert_settings()

app.settings.toggle_blindsigning()
app.assert_settings(blindsigning=True)

app.settings_toggle_blindsigning()
app.assert_screen("settings_blindsigning_on")
app.settings.toggle_expert_mode()
app.assert_settings(blindsigning=True, expert_mode=True)

app.settings_toggle_expert_mode()
app.assert_screen("settings_blindsigning_expert_on")
app.settings.toggle_blindsigning()
app.assert_settings(expert_mode=True)

app.settings_toggle_blindsigning()
app.assert_screen("settings_expert_on")
app.settings.toggle_expert_mode()
app.assert_settings()

app.settings_toggle_expert_mode()
app.assert_screen("settings_blindsigning_off")
app.settings.next()
app.assert_info()


app.info.next()
app.assert_screen(SCREEN_INFO_PAGE, True)

app.info.multi_page_exit()
app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.settings.exit()
app.assert_home()

app.quit()
44 changes: 18 additions & 26 deletions tests/integration/stax/test_blindsign_too_deep.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,55 @@
if __name__ == "__main__":
app = stax_app(__file__)

app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

# Blindsigning disabled (default state)
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.tap()
app.review.next()

app.assert_screen("tbtd_review_0")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
app.choice.confirm()

app.assert_screen("blindsign_enabled")
app.review.tap()
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()

app.assert_screen("blindsign_warning")
app.welcome.client.pause_ticker()
app.review.tap()
app.assert_screen("loading_operation")
app.welcome.client.resume_ticker()
with app.fading_screen("loading_operation"):
app.review.next()
app.send_apdu("800f82001211020000000c02000000070200000002002a")

app.assert_screen("tbtd_review_1")
app.review.tap()
app.review.next()
app.assert_screen("operation_sign")

expected_apdu = "93070b00990e4cf29c31f6497307bea0ad86a9d0dc08dba8b607e8dc0e23652f8309e41ed87ac1d33006806b688cfcff7632c4fbe499ff3ea4983ae4f06dea7790ec25db045689bca2c63967b5c563aabff86c4ef163bff92af3bb2ca9392d099000"
app.review_confirm_signing(expected_apdu)

app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

# Blindsign enabled
app.welcome.settings()
app.assert_screen("settings_blindsigning_on")
app.assert_settings(blindsigning=True)
# blind sign will be on because of previous test run.
app.info.multi_page_exit()
app.settings.exit()

app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app,"800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.tap()
app.review.next()
app.assert_screen("tbtd_review_0")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_blindsign_notify")
app.review.client.resume_ticker()
app.choice.confirm()

app.review.next()
app.assert_screen("blindsign_warning")
app.welcome.client.pause_ticker()
app.review.tap()
app.assert_screen("loading_operation")
app.welcome.client.resume_ticker()
with app.fading_screen("loading_operation"):
app.review.next()
app.send_apdu("800f82001211020000000c02000000070200000002002a")

app.assert_screen("tbtd_review_1")
app.review.tap()
app.review.next()

app.assert_screen("operation_sign")

Expand Down
78 changes: 31 additions & 47 deletions tests/integration/stax/test_blindsign_too_deep_rejections.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,97 +15,81 @@

from utils import *

def toggle_blindsigning():
app.assert_screen(SCREEN_HOME_DEFAULT, True)
def toggle_blindsigning(app):
app.assert_home()
app.welcome.settings()
app.settings_toggle_blindsigning()
app.info.multi_page_exit()
app.assert_screen(SCREEN_HOME_DEFAULT, True)

def toggle_expert_mode():
app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.welcome.settings()
app.settings_toggle_expert_mode()
app.info.multi_page_exit()
app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.settings.toggle_blindsigning()
app.settings.exit()
app.assert_home()

if __name__ == "__main__":
app = stax_app(__file__)

app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

# Rejecting at error screen (blindsign disabled)
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_expression")
app.review.tap()
app.review.next()
verify_err_reject_response(app, "too_deep_enable_blindsign")


# Rejecting at error screen (blindsign enabled)
toggle_blindsigning() # Enable blindsigning
app.assert_screen(SCREEN_HOME_DEFAULT, True)
toggle_blindsigning(app) # Enable blindsigning
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_expression")
app.review.tap()
app.review.next()
verify_err_reject_response(app, "too_deep_blindsign_notify")

# Rejecting at blindsigning splash screen
toggle_blindsigning() # Disable blindsigning at home
app.settings_toggle_blindsigning()
toggle_blindsigning(app) # Disable blindsigning at home
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_expression")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
app.choice.confirm()
app.assert_screen("blindsign_enabled")
app.review.tap()
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()
verify_err_reject_response(app,"blindsign_warning")

# Rejecting at blindsign review screen
toggle_blindsigning() # Disable blindsigning at home
toggle_blindsigning(app) # Disable blindsigning at home
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_expression")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
app.choice.confirm()
app.assert_screen("blindsign_enabled")
app.review.tap()
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()
app.assert_screen("blindsign_warning")
app.welcome.client.pause_ticker()
app.review.tap()
app.assert_screen("loading_operation")
app.welcome.client.resume_ticker()
with app.fading_screen("loading_operation"):
app.review.next()
app.send_apdu("800f82001211020000000c02000000070200000002002a")
verify_err_reject_response(app,"tbtd_review_1")


# Rejecting at final sign operation screen
toggle_blindsigning() # Disable blindsigning at home
toggle_blindsigning(app) # Disable blindsigning at home
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_expression")
app.review.tap()
app.review.next()
app.assert_screen("too_deep_enable_blindsign")
app.choice.confirm()
app.assert_screen("blindsign_enabled")
app.review.tap()
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()
app.assert_screen("blindsign_warning")
app.welcome.client.pause_ticker()
app.review.tap()
app.assert_screen("loading_operation")
app.welcome.client.resume_ticker()
with app.fading_screen("loading_operation"):
app.review.next()
app.send_apdu("800f82001211020000000c02000000070200000002002a")
app.assert_screen("tbtd_review_1")
app.review.tap()
app.review.next()
verify_err_reject_response(app,"operation_sign")

app.quit()
33 changes: 14 additions & 19 deletions tests/integration/stax/test_blindsign_too_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,48 @@
app = stax_app(__file__)

# Switch to blindsign mode
app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

# Blindsigning disabled (default state)
send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app, "800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a")
app.review.tap()
app.review.next()

app.assert_screen("too_large_enable_blindsign")
app.welcome.client.pause_ticker()
app.choice.confirm()

app.assert_screen("blindsign_enabled")
app.welcome.client.resume_ticker()

app.review.tap()
with app.fading_screen("blindsign_enabled"):
app.review.enable_blindsign.confirm()

app.assert_screen("blindsign_warning")
app.review.tap()
app.review.next()

app.assert_screen("tbtl_review_1")
app.review.tap()
app.review.next()
app.assert_screen("operation_sign")

expected_apdu = "ef565fa445d815cd77518a4d14ce90b7a536627455f0930c9dbfa22a75d478d83e2bcb333ba0d639dd28c1b77c5860e552ab02092a50a57f1424f573278230ab8ba81d8a40956415278a27e3f28cae64d1f1f13bf613e6e9a57035e9e14511029000"
app.review_confirm_signing(expected_apdu)

app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

# Blindsign enabled
app.welcome.settings()
app.assert_screen("settings_blindsigning_on")
app.assert_settings(blindsigning=True)
# blind sign will be on because of previous test run.
app.info.multi_page_exit()
app.settings.exit()

app.assert_screen(SCREEN_HOME_DEFAULT, True)
app.assert_home()

send_initialize_msg(app, "800f000011048000002c800006c18000000080000000")
send_payload(app,"800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a")
app.review.tap()
app.review.next()
app.assert_screen("too_large_blindsign_notify")
app.choice.confirm()
app.review.next()

app.assert_screen("blindsign_warning")
app.review.tap()
app.review.next()

app.assert_screen("tbtl_review_1")
app.review.tap()
app.review.next()
app.assert_screen("operation_sign")

expected_apdu = "ef565fa445d815cd77518a4d14ce90b7a536627455f0930c9dbfa22a75d478d83e2bcb333ba0d639dd28c1b77c5860e552ab02092a50a57f1424f573278230ab8ba81d8a40956415278a27e3f28cae64d1f1f13bf613e6e9a57035e9e14511029000"
Expand Down
Loading

0 comments on commit e624d29

Please sign in to comment.