Skip to content
Open
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
24 changes: 21 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
account_info::{next_account_info, AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
pubkey::Pubkey,
rent::Rent,
sysvar::Sysvar,
};

entrypoint!(process_instruction);
Expand All @@ -14,6 +20,15 @@ fn process_instruction(
accounts.len(),
instruction_data
);

let account_info_iter = &mut accounts.iter();
let rent_sysvar_account_info = next_account_info(account_info_iter)?;
let rent = &Rent::from_account_info(rent_sysvar_account_info)?;
msg!(
"Rent exemption minimum lamport balance for an account that's 123 bytes in size: {}",
rent.minimum_balance(123)
);

Ok(())
}

Expand All @@ -22,7 +37,10 @@ mod test {
use {
super::*,
assert_matches::*,
solana_program::instruction::{AccountMeta, Instruction},
solana_program::{
instruction::{AccountMeta, Instruction},
sysvar,
},
solana_program_test::*,
solana_sdk::{signature::Signer, transaction::Transaction},
};
Expand All @@ -42,7 +60,7 @@ mod test {
let mut transaction = Transaction::new_with_payer(
&[Instruction {
program_id,
accounts: vec![AccountMeta::new(payer.pubkey(), false)],
accounts: vec![AccountMeta::new_readonly(sysvar::rent::id(), false)],
data: vec![1, 2, 3],
}],
Some(&payer.pubkey()),
Expand Down
3 changes: 2 additions & 1 deletion tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use {
solana_program::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
sysvar,
},
solana_sdk::{signature::Signer, transaction::Transaction},
solana_validator::test_validator::*,
Expand All @@ -22,7 +23,7 @@ fn test_validator_transaction() {
let mut transaction = Transaction::new_with_payer(
&[Instruction {
program_id,
accounts: vec![AccountMeta::new(payer.pubkey(), false)],
accounts: vec![AccountMeta::new_readonly(sysvar::rent::id(), false)],
data: vec![1, 2, 3],
}],
Some(&payer.pubkey()),
Expand Down