|
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}; |
4 | 2 | use solana_program_test::*;
|
5 | 3 | use solana_sdk::{
|
6 | 4 | signature::Signer,
|
@@ -49,9 +47,13 @@ async fn test_associated_token_address() {
|
49 | 47 | let associated_token_address =
|
50 | 48 | get_associated_token_address(&wallet_address, &token_mint_address);
|
51 | 49 |
|
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; |
55 | 57 | let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
|
56 | 58 |
|
57 | 59 | // Associated account does not exist
|
@@ -95,9 +97,13 @@ async fn test_create_with_a_lamport() {
|
95 | 97 | let associated_token_address =
|
96 | 98 | get_associated_token_address(&wallet_address, &token_mint_address);
|
97 | 99 |
|
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; |
101 | 107 | let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
|
102 | 108 |
|
103 | 109 | // Transfer 1 lamport into `associated_token_address` before creating it
|
@@ -148,9 +154,13 @@ async fn test_create_with_excess_lamports() {
|
148 | 154 | let associated_token_address =
|
149 | 155 | get_associated_token_address(&wallet_address, &token_mint_address);
|
150 | 156 |
|
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; |
154 | 164 | let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
|
155 | 165 |
|
156 | 166 | // Transfer 1 lamport into `associated_token_address` before creating it
|
@@ -201,8 +211,13 @@ async fn test_create_account_mismatch() {
|
201 | 211 | let _associated_token_address =
|
202 | 212 | get_associated_token_address(&wallet_address, &token_mint_address);
|
203 | 213 |
|
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); |
206 | 221 |
|
207 | 222 | let mut instruction =
|
208 | 223 | create_associated_token_account(&payer.pubkey(), &wallet_address, &token_mint_address);
|
|
0 commit comments