diff --git a/programs/mango-v4/tests/program_test/mango_client.rs b/programs/mango-v4/tests/program_test/mango_client.rs index 414d833e1..e0169b8a2 100644 --- a/programs/mango-v4/tests/program_test/mango_client.rs +++ b/programs/mango-v4/tests/program_test/mango_client.rs @@ -5,6 +5,7 @@ use anchor_lang::Key; use anchor_spl::token::{Token, TokenAccount}; use solana_sdk::instruction; use solana_sdk::signature::{Keypair, Signer}; +use solana_sdk::transport::TransportError; #[async_trait::async_trait(?Send)] pub trait ClientAccountLoader { @@ -23,15 +24,17 @@ impl ClientAccountLoader for &SolanaCookie { } // TODO: report error outwards etc -pub async fn send_tx(solana: &SolanaCookie, ix: CI) -> CI::Accounts { +pub async fn send_tx( + solana: &SolanaCookie, + ix: CI, +) -> std::result::Result { let (accounts, instruction) = ix.to_instruction(solana).await; let signers = ix.signers(); let instructions = vec![instruction]; solana .process_transaction(&instructions, Some(&signers[..])) - .await - .unwrap(); - accounts + .await?; + Ok(accounts) } #[async_trait::async_trait(?Send)] diff --git a/programs/mango-v4/tests/test_basic.rs b/programs/mango-v4/tests/test_basic.rs index 4f129839e..f2bf2fbf4 100644 --- a/programs/mango-v4/tests/test_basic.rs +++ b/programs/mango-v4/tests/test_basic.rs @@ -25,11 +25,12 @@ async fn test_basic() -> Result<(), TransportError> { let dust_threshold = 0.01; // - // SETUP: Create a group, register a token (mint0) + // SETUP: Create a group, account, register a token (mint0) // let group = send_tx(solana, CreateGroupInstruction { admin, payer }) .await + .unwrap() .group; let account = send_tx( @@ -42,6 +43,7 @@ async fn test_basic() -> Result<(), TransportError> { }, ) .await + .unwrap() .account; let register_token_accounts = send_tx( @@ -58,7 +60,8 @@ async fn test_basic() -> Result<(), TransportError> { payer, }, ) - .await; + .await + .unwrap(); let bank = register_token_accounts.bank; let vault = register_token_accounts.vault; @@ -79,7 +82,8 @@ async fn test_basic() -> Result<(), TransportError> { token_authority: payer, }, ) - .await; + .await + .unwrap(); assert_eq!(solana.token_account_balance(vault).await, deposit_amount); assert_eq!( @@ -117,7 +121,8 @@ async fn test_basic() -> Result<(), TransportError> { banks: vec![bank], }, ) - .await; + .await + .unwrap(); assert_eq!(solana.token_account_balance(vault).await, withdraw_amount); assert_eq!(