From 567e2abb32f8026d7eec218623f797c390935520 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Tue, 3 Dec 2024 15:42:23 -0500 Subject: [PATCH] fix: fix tests --- .../tests/it/integration/emulator.rs | 34 ++++++++----------- .../soroban-test/tests/it/integration/util.rs | 4 --- cmd/stellar-cli/Cargo.toml | 1 + 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/cmd/crates/soroban-test/tests/it/integration/emulator.rs b/cmd/crates/soroban-test/tests/it/integration/emulator.rs index 9c4ccd1c0..da13db2d7 100644 --- a/cmd/crates/soroban-test/tests/it/integration/emulator.rs +++ b/cmd/crates/soroban-test/tests/it/integration/emulator.rs @@ -1,12 +1,8 @@ use stellar_ledger::{Blob, Error}; -use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE}; -use std::sync::Arc; - -use soroban_cli::xdr::{ - self, Memo, MuxedAccount, Operation, OperationBody, PaymentOp, Preconditions, SequenceNumber, - Transaction, TransactionExt, Uint256, -}; +use soroban_test::{AssertExt, TestEnv}; +use std::{sync::Arc, time::Duration}; +use tokio::time::sleep; use stellar_ledger::emulator_test_support::*; @@ -14,11 +10,11 @@ use test_case::test_case; use crate::integration::util::{deploy_contract, DeployKind, HELLO_WORLD}; -// #[test_case("nanos"; "when the device is NanoS")] -#[test_case("nanox"; "when the device is NanoX")] -// #[test_case("nanosp"; "when the device is NanoS Plus")] +#[test_case("nanos", 0; "when the device is NanoS")] +#[test_case("nanox", 1; "when the device is NanoX")] +#[test_case("nanosp",2; "when the device is NanoS Plus")] #[tokio::test] -async fn test_get_public_key(ledger_device_model: &str) { +async fn test_get_public_key(ledger_device_model: &str, hd_path: u32) { let sandbox = Arc::new(TestEnv::new()); let container = TestEnv::speculos_container(ledger_device_model).await; let host_port = container.get_host_port_ipv4(9998).await.unwrap(); @@ -26,25 +22,21 @@ async fn test_get_public_key(ledger_device_model: &str) { let ledger = ledger(host_port).await; - let key = ledger.get_public_key(&0.into()).await.unwrap(); + let key = ledger.get_public_key(&hd_path.into()).await.unwrap(); let account = &key.to_string(); sandbox.fund_account(account); + sleep(Duration::from_secs(hd_path as u64)).await; sandbox .new_assert_cmd("contract") .arg("install") - .args([ - "--wasm", - HELLO_WORLD.path().as_os_str().to_str().unwrap(), - "--source", - account, - ]) + .args(["--wasm", HELLO_WORLD.path().as_os_str().to_str().unwrap()]) .assert() .success(); let tx_simulated = deploy_contract(&sandbox, HELLO_WORLD, DeployKind::SimOnly, Some(account)).await; dbg!("{tx_simulated}"); - let key = ledger.get_public_key(&0.into()).await.unwrap(); + let key = ledger.get_public_key(&hd_path.into()).await.unwrap(); println!("{key}"); let sign = tokio::task::spawn_blocking({ let sandbox = Arc::clone(&sandbox); @@ -54,6 +46,8 @@ async fn test_get_public_key(ledger_device_model: &str) { .new_assert_cmd("tx") .arg("sign") .arg("--sign-with-ledger") + .arg("--hd-path") + .arg(hd_path.to_string()) .write_stdin(tx_simulated.as_bytes()) .env("SPECULOS_PORT", host_port.to_string()) .env("RUST_LOGS", "trace") @@ -70,7 +64,7 @@ async fn test_get_public_key(ledger_device_model: &str) { let response = sign.await.unwrap(); approve.await.unwrap(); - dbg!("{tx_signed}"); + dbg!("{tx_signed:#?}"); sandbox .clone() diff --git a/cmd/crates/soroban-test/tests/it/integration/util.rs b/cmd/crates/soroban-test/tests/it/integration/util.rs index 486b00a1b..dcee95204 100644 --- a/cmd/crates/soroban-test/tests/it/integration/util.rs +++ b/cmd/crates/soroban-test/tests/it/integration/util.rs @@ -24,8 +24,6 @@ where assert_eq!(res, data); } -pub const TEST_SALT: &str = "f55ff16f66f43360266b95db6f8fec01d76031054306ae4a4b380598f6cfd114"; - pub enum DeployKind { BuildOnly, Normal, @@ -70,8 +68,6 @@ pub async fn deploy_contract( "1000000", "--wasm", &wasm.path().to_string_lossy(), - "--salt", - TEST_SALT, "--ignore-checks", &deploy.to_string(), ], diff --git a/cmd/stellar-cli/Cargo.toml b/cmd/stellar-cli/Cargo.toml index e1f1dce6b..4a2808f6f 100644 --- a/cmd/stellar-cli/Cargo.toml +++ b/cmd/stellar-cli/Cargo.toml @@ -27,6 +27,7 @@ bin-dir = "{ bin }{ binary-ext }" [features] default = [] opt = ["soroban-cli/opt"] +emulator-tests = ["soroban-cli/emulator-tests"] [dependencies] soroban-cli = { workspace = true }