Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 20551f9

Browse files
mvinesmergify[bot]
authored andcommitted
1 parent 4da9cb3 commit 20551f9

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

associated-token-account/program/tests/functional.rs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use solana_program::{
2-
instruction::*, program_pack::Pack, pubkey::Pubkey, system_instruction, sysvar::rent::Rent,
3-
};
1+
use solana_program::{instruction::*, program_pack::Pack, pubkey::Pubkey, system_instruction};
42
use solana_program_test::*;
53
use solana_sdk::{
64
signature::Signer,
@@ -49,9 +47,13 @@ async fn test_associated_token_address() {
4947
let associated_token_address =
5048
get_associated_token_address(&wallet_address, &token_mint_address);
5149

52-
let (mut banks_client, payer, recent_blockhash) =
53-
program_test(token_mint_address).start().await;
54-
let rent = Rent::default(); // <-- TODO: get Rent from `ProgramTest`
50+
let StartOutputs {
51+
mut banks_client,
52+
payer,
53+
recent_blockhash,
54+
rent,
55+
..
56+
} = program_test().start().await;
5557
let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
5658

5759
// Associated account does not exist
@@ -95,9 +97,13 @@ async fn test_create_with_a_lamport() {
9597
let associated_token_address =
9698
get_associated_token_address(&wallet_address, &token_mint_address);
9799

98-
let (mut banks_client, payer, recent_blockhash) =
99-
program_test(token_mint_address).start().await;
100-
let rent = Rent::default(); // <-- TOOD: get Rent from `ProgramTest`
100+
let StartOutputs {
101+
mut banks_client,
102+
payer,
103+
recent_blockhash,
104+
rent,
105+
..
106+
} = program_test().start().await;
101107
let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
102108

103109
// Transfer 1 lamport into `associated_token_address` before creating it
@@ -148,9 +154,13 @@ async fn test_create_with_excess_lamports() {
148154
let associated_token_address =
149155
get_associated_token_address(&wallet_address, &token_mint_address);
150156

151-
let (mut banks_client, payer, recent_blockhash) =
152-
program_test(token_mint_address).start().await;
153-
let rent = Rent::default(); // <-- TOOD: get Rent from `ProgramTest`
157+
let StartOutputs {
158+
mut banks_client,
159+
payer,
160+
recent_blockhash,
161+
rent,
162+
..
163+
} = program_test().start().await;
154164
let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
155165

156166
// Transfer 1 lamport into `associated_token_address` before creating it
@@ -201,8 +211,13 @@ async fn test_create_account_mismatch() {
201211
let _associated_token_address =
202212
get_associated_token_address(&wallet_address, &token_mint_address);
203213

204-
let (mut banks_client, payer, recent_blockhash) =
205-
program_test(token_mint_address).start().await;
214+
let StartOutputs {
215+
mut banks_client,
216+
payer,
217+
recent_blockhash,
218+
..
219+
} = program_test().start().await;
220+
let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
206221

207222
let mut instruction =
208223
create_associated_token_account(&payer.pubkey(), &wallet_address, &token_mint_address);

0 commit comments

Comments
 (0)