Skip to content

Commit

Permalink
Test sign_tx_hash with 3 ledger devices
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed May 8, 2024
1 parent 085ba0f commit 4ed97fb
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions cmd/crates/stellar-ledger/src/emulator_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit 4ed97fb

Please sign in to comment.