diff --git a/cmd/crates/stellar-ledger/src/emulator_tests.rs b/cmd/crates/stellar-ledger/src/emulator_tests.rs index 4230b958d4..37c73f5686 100644 --- a/cmd/crates/stellar-ledger/src/emulator_tests.rs +++ b/cmd/crates/stellar-ledger/src/emulator_tests.rs @@ -121,9 +121,20 @@ async fn test_get_app_configuration(image_args: Args) { } #[tokio::test] -async fn test_sign_tx() { +async fn test_sign_tx_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 for {device_model}"); + test_sign_tx(args).await; + } +} +async fn test_sign_tx(image_args: Args) { let docker = clients::Cli::default(); - let node = docker.run((Speculos::new(), Args::default())); + let node = docker.run((Speculos::new(), image_args.clone())); + let host_port = node.get_host_port_ipv4(9998); let ui_host_port: u16 = node.get_host_port_ipv4(5000); @@ -192,7 +203,8 @@ async fn test_sign_tx() { let ledger = Arc::clone(&ledger); async move { ledger.sign_transaction(path, tx).await } }); - let approve = tokio::task::spawn(approve_tx_signature(ui_host_port)); + let args = image_args.clone(); + let approve = tokio::task::spawn(approve_tx_signature(ui_host_port, args.ledger_device_model)); let result = sign.await.unwrap(); let _ = approve.await.unwrap(); @@ -428,14 +440,17 @@ async fn approve_tx_hash_signature(ui_host_port: u16) { click(ui_host_port, "button/both").await; } -async fn approve_tx_signature(ui_host_port: u16) { +async fn approve_tx_signature(ui_host_port: u16, device_model: String) { println!("approving tx on the device"); let mut map = HashMap::new(); map.insert("action", "press-and-release"); // press right button 17 times + // for sp and nanox it should only be 11 times + + let number_of_right_clicks = if device_model == "nanos" { 17 } else { 11 }; let client = reqwest::Client::new(); - for _ in 0..17 { + for _ in 0..number_of_right_clicks { client .post(format!("http://localhost:{ui_host_port}/button/right")) .json(&map)