44 prelude:: { AccountMeta , Pubkey } ,
55 ToAccountMetas ,
66 } ,
7- bonfida_test_utils:: ProgramTestContextExt ,
87 perpetuals:: {
98 instructions:: AddLiquidityParams ,
109 state:: { custody:: Custody , pool:: Pool } ,
1110 } ,
1211 solana_program_test:: { BanksClientError , ProgramTestContext } ,
1312 solana_sdk:: signer:: { keypair:: Keypair , Signer } ,
13+ tokio:: sync:: RwLock ,
1414} ;
1515
1616pub async fn test_add_liquidity (
17- program_test_ctx : & mut ProgramTestContext ,
17+ program_test_ctx : & RwLock < ProgramTestContext > ,
1818 owner : & Keypair ,
1919 payer : & Keypair ,
2020 pool_pda : & Pubkey ,
@@ -39,18 +39,12 @@ pub async fn test_add_liquidity(
3939 let custody_oracle_account_address = custody_account. oracle . oracle_account ;
4040
4141 // Save account state before tx execution
42- let owner_funding_account_before = program_test_ctx
43- . get_token_account ( funding_account_address)
44- . await
45- . unwrap ( ) ;
46- let owner_lp_token_account_before = program_test_ctx
47- . get_token_account ( lp_token_account_address)
48- . await
49- . unwrap ( ) ;
50- let custody_token_account_before = program_test_ctx
51- . get_token_account ( custody_token_account_pda)
52- . await
53- . unwrap ( ) ;
42+ let owner_funding_account_before =
43+ utils:: get_token_account ( program_test_ctx, funding_account_address) . await ;
44+ let owner_lp_token_account_before =
45+ utils:: get_token_account ( program_test_ctx, lp_token_account_address) . await ;
46+ let custody_token_account_before =
47+ utils:: get_token_account ( program_test_ctx, custody_token_account_pda) . await ;
5448
5549 let accounts_meta = {
5650 let accounts = perpetuals:: accounts:: AddLiquidity {
@@ -100,22 +94,18 @@ pub async fn test_add_liquidity(
10094 perpetuals:: instruction:: AddLiquidity { params } ,
10195 Some ( & payer. pubkey ( ) ) ,
10296 & [ owner, payer] ,
97+ None ,
98+ None ,
10399 )
104100 . await ?;
105101
106102 // ==== THEN ==============================================================
107- let owner_funding_account_after = program_test_ctx
108- . get_token_account ( funding_account_address)
109- . await
110- . unwrap ( ) ;
111- let owner_lp_token_account_after = program_test_ctx
112- . get_token_account ( lp_token_account_address)
113- . await
114- . unwrap ( ) ;
115- let custody_token_account_after = program_test_ctx
116- . get_token_account ( custody_token_account_pda)
117- . await
118- . unwrap ( ) ;
103+ let owner_funding_account_after =
104+ utils:: get_token_account ( program_test_ctx, funding_account_address) . await ;
105+ let owner_lp_token_account_after =
106+ utils:: get_token_account ( program_test_ctx, lp_token_account_address) . await ;
107+ let custody_token_account_after =
108+ utils:: get_token_account ( program_test_ctx, custody_token_account_pda) . await ;
119109
120110 assert ! ( owner_funding_account_after. amount < owner_funding_account_before. amount) ;
121111 assert ! ( owner_lp_token_account_after. amount > owner_lp_token_account_before. amount) ;
0 commit comments