Fixup tests to use rent-exempt accounts (#2717)
This commit is contained in:
parent
f4e0cae144
commit
7fd1b6b75f
|
@ -67,7 +67,7 @@ async fn test_associated_token_address() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_create_with_a_lamport() {
|
async fn test_create_with_fewer_lamports() {
|
||||||
let wallet_address = Pubkey::new_unique();
|
let wallet_address = Pubkey::new_unique();
|
||||||
let token_mint_address = Pubkey::new_unique();
|
let token_mint_address = Pubkey::new_unique();
|
||||||
let associated_token_address =
|
let associated_token_address =
|
||||||
|
@ -78,12 +78,13 @@ async fn test_create_with_a_lamport() {
|
||||||
let rent = banks_client.get_rent().await.unwrap();
|
let rent = banks_client.get_rent().await.unwrap();
|
||||||
let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
|
let expected_token_account_balance = rent.minimum_balance(spl_token::state::Account::LEN);
|
||||||
|
|
||||||
// Transfer 1 lamport into `associated_token_address` before creating it
|
// Transfer lamports into `associated_token_address` before creating it - enough to be
|
||||||
|
// rent-exempt for 0 data, but not for an initialized token account
|
||||||
let mut transaction = Transaction::new_with_payer(
|
let mut transaction = Transaction::new_with_payer(
|
||||||
&[system_instruction::transfer(
|
&[system_instruction::transfer(
|
||||||
&payer.pubkey(),
|
&payer.pubkey(),
|
||||||
&associated_token_address,
|
&associated_token_address,
|
||||||
1,
|
rent.minimum_balance(0),
|
||||||
)],
|
)],
|
||||||
Some(&payer.pubkey()),
|
Some(&payer.pubkey()),
|
||||||
);
|
);
|
||||||
|
@ -95,7 +96,7 @@ async fn test_create_with_a_lamport() {
|
||||||
.get_balance(associated_token_address)
|
.get_balance(associated_token_address)
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
1
|
rent.minimum_balance(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check that the program adds the extra lamports
|
// Check that the program adds the extra lamports
|
||||||
|
|
|
@ -43,12 +43,14 @@ async fn test_name_service() {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let space = 1_000usize;
|
||||||
|
let rent = ctx.banks_client.get_rent().await.unwrap();
|
||||||
let create_name_instruction = create(
|
let create_name_instruction = create(
|
||||||
program_id,
|
program_id,
|
||||||
NameRegistryInstruction::Create {
|
NameRegistryInstruction::Create {
|
||||||
hashed_name: hashed_root_name,
|
hashed_name: hashed_root_name,
|
||||||
lamports: 1_000_000,
|
lamports: rent.minimum_balance(space + NameRecordHeader::LEN),
|
||||||
space: 1_000,
|
space: space as u32,
|
||||||
},
|
},
|
||||||
root_name_account_key,
|
root_name_account_key,
|
||||||
ctx.payer.pubkey(),
|
ctx.payer.pubkey(),
|
||||||
|
@ -91,8 +93,8 @@ async fn test_name_service() {
|
||||||
program_id,
|
program_id,
|
||||||
NameRegistryInstruction::Create {
|
NameRegistryInstruction::Create {
|
||||||
hashed_name,
|
hashed_name,
|
||||||
lamports: 1_000_000,
|
lamports: rent.minimum_balance(space + NameRecordHeader::LEN),
|
||||||
space: 1_000,
|
space: space as u32,
|
||||||
},
|
},
|
||||||
name_account_key,
|
name_account_key,
|
||||||
ctx.payer.pubkey(),
|
ctx.payer.pubkey(),
|
||||||
|
|
Loading…
Reference in New Issue