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