Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn test_associated_token_address() {
}

#[tokio::test]
async fn test_create_with_a_lamport() {
async fn test_create_with_fewer_lamports() {
let wallet_address = Pubkey::new_unique();
let token_mint_address = Pubkey::new_unique();
let associated_token_address =
Expand All @@ -78,12 +78,13 @@ async fn test_create_with_a_lamport() {
let rent = banks_client.get_rent().await.unwrap();
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(
&[system_instruction::transfer(
&payer.pubkey(),
&associated_token_address,
1,
rent.minimum_balance(0),
)],
Some(&payer.pubkey()),
);
Expand All @@ -95,7 +96,7 @@ async fn test_create_with_a_lamport() {
.get_balance(associated_token_address)
.await
.unwrap(),
1
rent.minimum_balance(0)
);

// Check that the program adds the extra lamports
Expand Down
10 changes: 6 additions & 4 deletions name-service/program/tests/functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ async fn test_name_service() {
None,
);

let space = 1_000usize;
let rent = ctx.banks_client.get_rent().await.unwrap();
let create_name_instruction = create(
program_id,
NameRegistryInstruction::Create {
hashed_name: hashed_root_name,
lamports: 1_000_000,
space: 1_000,
lamports: rent.minimum_balance(space + NameRecordHeader::LEN),
space: space as u32,
},
root_name_account_key,
ctx.payer.pubkey(),
Expand Down Expand Up @@ -91,8 +93,8 @@ async fn test_name_service() {
program_id,
NameRegistryInstruction::Create {
hashed_name,
lamports: 1_000_000,
space: 1_000,
lamports: rent.minimum_balance(space + NameRecordHeader::LEN),
space: space as u32,
},
name_account_key,
ctx.payer.pubkey(),
Expand Down