Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Nov 3, 2020
1 parent d0ef13c commit 357298a
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions associated-account/program/tests/functional.rs
@@ -1,6 +1,4 @@
use solana_program::{
instruction::*, program_pack::Pack, pubkey::Pubkey, system_instruction, sysvar::rent::Rent,
};
use solana_program::{instruction::*, program_pack::Pack, pubkey::Pubkey, system_instruction};
use solana_program_test::*;
use solana_sdk::{
signature::Signer,
Expand Down Expand Up @@ -55,9 +53,13 @@ async fn test_associated_token_account() {
let associated_token_account =
get_associated_token_address(&user_wallet_address, &token_mint_address);

let (mut banks_client, payer, recent_blockhash) =
program_test_with_mint(token_mint_address).start().await;
let rent = Rent::default(); // <-- TOOD: get Rent from `ProgramTest`
let StartOutputs {
mut banks_client,
payer,
recent_blockhash,
rent,
..
} = program_test_with_mint(token_mint_address).start().await;

// Associated account does not exist
assert_eq!(
Expand Down Expand Up @@ -99,7 +101,12 @@ async fn test_associated_token_account() {

#[tokio::test]
async fn test_invalid_instruction_data() {
let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
let StartOutputs {
mut banks_client,
payer,
recent_blockhash,
..
} = program_test().start().await;

let mut transaction = Transaction::new_with_payer(
&[Instruction {
Expand Down Expand Up @@ -133,7 +140,12 @@ async fn test_create_with_a_lamport() {
)
.0;

let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
let StartOutputs {
mut banks_client,
payer,
recent_blockhash,
..
} = program_test().start().await;

// Transfer 1 lamport into `assocated_account_address` before creating it
let mut transaction = Transaction::new_with_payer(
Expand Down Expand Up @@ -199,7 +211,12 @@ async fn test_create_with_excess_lamports() {
)
.0;

let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
let StartOutputs {
mut banks_client,
payer,
recent_blockhash,
..
} = program_test().start().await;

// Transfer 100 lamports into `assocated_account_address` before creating it
let mut transaction = Transaction::new_with_payer(
Expand Down Expand Up @@ -265,7 +282,12 @@ async fn test_create_account_mismatch() {
)
.0;

let (mut banks_client, payer, recent_blockhash) = program_test().start().await;
let StartOutputs {
mut banks_client,
payer,
recent_blockhash,
..
} = program_test().start().await;

let mut transaction = Transaction::new_with_payer(
&[Instruction {
Expand Down

0 comments on commit 357298a

Please sign in to comment.