From 4ed97fbefa9f6c87cc72118cb7d50d47ebe35800 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Wed, 8 May 2024 14:15:01 -0400 Subject: [PATCH] Test sign_tx_hash with 3 ledger devices --- .../stellar-ledger/src/emulator_tests.rs | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/cmd/crates/stellar-ledger/src/emulator_tests.rs b/cmd/crates/stellar-ledger/src/emulator_tests.rs index dd035aa346..4230b958d4 100644 --- a/cmd/crates/stellar-ledger/src/emulator_tests.rs +++ b/cmd/crates/stellar-ledger/src/emulator_tests.rs @@ -42,6 +42,7 @@ async fn test_get_public_key_for_different_ledger_devices() { let args = Args { ledger_device_model: device_model.to_string(), }; + println!("Running test_get_public_key for {device_model}"); test_get_public_key(args).await; } } @@ -85,6 +86,7 @@ async fn test_get_app_configuration_for_different_ledger_devices() { let args = Args { ledger_device_model: device_model.to_string(), }; + println!("Running test_get_app_configuration for {device_model}"); test_get_app_configuration(args).await; } } @@ -210,10 +212,21 @@ async fn test_sign_tx() { } #[tokio::test] -async fn test_sign_tx_hash_when_hash_signing_is_not_enabled() { +async fn test_sign_tx_hash_when_hash_signing_is_not_enabled_for_different_ledger_devices() { + let device_models = ["nanos", "nanox", "nanosp"]; + for device_model in device_models.iter() { + let args = Args { + ledger_device_model: device_model.to_string(), + }; + println!("Running test_sign_tx_hash_when_hash_signing_is_not_enabled for {device_model}"); + test_sign_tx_hash_when_hash_signing_is_not_enabled(args).await; + } +} +async fn test_sign_tx_hash_when_hash_signing_is_not_enabled(image_args: Args) { //when hash signing isn't enabled on the device we expect an error let docker = clients::Cli::default(); - let node = docker.run(Speculos::new()); + let args = image_args.clone(); + let node = docker.run((Speculos::new(), args)); let host_port = node.get_host_port_ipv4(9998); let ui_host_port: u16 = node.get_host_port_ipv4(5000); @@ -245,7 +258,17 @@ async fn test_sign_tx_hash_when_hash_signing_is_not_enabled() { } #[tokio::test] -async fn test_sign_tx_hash_when_hash_signing_is_enabled() { +async fn test_sign_tx_hash_when_hash_signing_is_enabled_for_different_ledger_devices() { + let device_models = ["nanos", "nanosp", "nanox"]; + for device_model in device_models.iter() { + let args = Args { + ledger_device_model: device_model.to_string(), + }; + println!("Running test_sign_tx_hash_when_hash_signing_is_enabled for {device_model}"); + test_sign_tx_hash_when_hash_signing_is_enabled(args).await; + } +} +async fn test_sign_tx_hash_when_hash_signing_is_enabled(image_args: Args) { //when hash signing isnt enabled on the device we expect an error let docker = clients::Cli::default(); let node = docker.run(Speculos::new()); @@ -329,6 +352,7 @@ async fn click(ui_host_port: u16, url: &str) { async fn enable_hash_signing(ui_host_port: u16) { println!("enabling hash signing on the device"); + // enable hash signing // right button press click(ui_host_port, "button/right").await; @@ -338,6 +362,7 @@ async fn enable_hash_signing(ui_host_port: u16) { // both button press click(ui_host_port, "button/both").await; + // get back to main menu // right button press click(ui_host_port, "button/right").await;