Rent tangential stuff (#5910)

* rename rent.rs to rent_calculator.rs

* add rent sysvar

* integrate rent_calculator with bank

* rent_calculator integration with genesis

* add test for rent sysvar
This commit is contained in:
Parth
2019-09-17 17:12:55 +05:30
committed by GitHub
parent b31d334ef4
commit d63518a835
11 changed files with 157 additions and 30 deletions

View File

@@ -7,8 +7,9 @@ use solana_sdk::{
entrypoint,
entrypoint::SUCCESS,
pubkey::Pubkey,
rent_calculator,
sysvar::{
clock::Clock, fees::Fees, rewards::Rewards, slot_hashes::SlotHashes,
clock::Clock, fees::Fees, rent::Rent, rewards::Rewards, slot_hashes::SlotHashes,
stake_history::StakeHistory,
},
};
@@ -39,5 +40,16 @@ fn process_instruction(_program_id: &Pubkey, accounts: &mut [AccountInfo], _data
let stake_history = StakeHistory::from_account_info(&accounts[6]).unwrap();
assert_eq!(stake_history.len(), 1);
let rent = Rent::from_account_info(&accounts[7]).unwrap();
assert_eq!(
rent.rent_calculator.due(
rent_calculator::DEFAULT_LAMPORTS_PER_BYTE_YEAR
* rent_calculator::DEFAULT_EXEMPTION_THRESHOLD as u64,
1,
1.0
),
(0, true)
);
SUCCESS
}

View File

@@ -83,7 +83,7 @@ mod bpf {
use solana_sdk::instruction::{AccountMeta, Instruction};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::sysvar::{clock, fees, rewards, slot_hashes, stake_history};
use solana_sdk::sysvar::{clock, fees, rewards, slot_hashes, stake_history, rent};
use std::io::Read;
use std::sync::Arc;
@@ -132,6 +132,7 @@ mod bpf {
AccountMeta::new(rewards::id(), false),
AccountMeta::new(slot_hashes::id(), false),
AccountMeta::new(stake_history::id(), false),
AccountMeta::new(rent::id(), false)
];
let instruction = Instruction::new(program_id, &1u8, account_metas);
let result = bank_client.send_instruction(&mint_keypair, instruction);