Skip to content

Commit

Permalink
fix: pass emulator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed May 16, 2024
1 parent 69069a0 commit 091beff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
24 changes: 10 additions & 14 deletions cmd/crates/stellar-ledger/src/emulator_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ use tokio::time::sleep;

const TEST_NETWORK_PASSPHRASE: &str = "Test SDF Network ; September 2015";

fn ledger(host_port: u16) -> LedgerSigner<impl Exchange> {
LedgerSigner::new(get_zemu_transport("127.0.0.1", host_port).unwrap())
}

// #[ignore]
// #[tokio::test]
// #[serial]
Expand All @@ -44,9 +48,7 @@ async fn test_get_public_key() {

wait_for_emulator_start_text(ui_host_port).await;

let transport = get_zemu_transport("127.0.0.1", host_port).unwrap();

let ledger = native().unwrap();
let ledger = ledger(host_port);

match ledger.get_public_key(&0.into()).await {
Ok(public_key) => {
Expand Down Expand Up @@ -75,8 +77,7 @@ async fn test_get_app_configuration() {

wait_for_emulator_start_text(ui_host_port).await;

let transport = get_zemu_transport("127.0.0.1", host_port).unwrap();
let ledger = native().unwrap();
let ledger = ledger(host_port);

match ledger.get_app_configuration().await {
Ok(config) => {
Expand All @@ -101,8 +102,7 @@ async fn test_sign_tx() {

wait_for_emulator_start_text(ui_host_port).await;

let transport = get_zemu_transport("127.0.0.1", host_port).unwrap();
let ledger = Arc::new(native().unwrap());
let ledger = Arc::new(ledger(host_port));

let path = HdPath(0);

Expand Down Expand Up @@ -192,9 +192,7 @@ async fn test_sign_tx_hash_when_hash_signing_is_not_enabled() {
// sleep to account for key delay
// for some things, waiting for the screen to change... but prob dont need that for this

let transport = get_zemu_transport("127.0.0.1", host_port).unwrap();

let ledger = native().unwrap();
let ledger = ledger(host_port);

let path = 0;
let test_hash = b"313e8447f569233bb8db39aa607c8889";
Expand Down Expand Up @@ -222,15 +220,13 @@ async fn test_sign_tx_hash_when_hash_signing_is_enabled() {
wait_for_emulator_start_text(ui_host_port).await;
enable_hash_signing(ui_host_port).await;

let transport = get_zemu_transport("127.0.0.1", host_port).unwrap();

let ledger = Arc::new(native().unwrap());
let ledger = Arc::new(ledger(host_port));

let path = 0;
let mut test_hash = [0u8; 32];

match hex::decode_to_slice(
"313e8447f569233bb8db39aa607c8889",
"313e8447f569233bb8db39aa607c8889313e8447f569233bb8db39aa607c8889",
&mut test_hash as &mut [u8],
) {
Ok(()) => {}
Expand Down
2 changes: 1 addition & 1 deletion cmd/crates/stellar-ledger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ mod test {

use soroban_env_host::xdr::{self, Operation, OperationBody, Uint256};

use crate::{Error, LedgerSigner, test_network_hash};
use crate::{test_network_hash, Error, LedgerSigner};

use stellar_xdr::curr::{
Memo, MuxedAccount, PaymentOp, Preconditions, SequenceNumber, TransactionExt,
Expand Down

0 comments on commit 091beff

Please sign in to comment.