Skip to content

Commit

Permalink
Include Rent in ProgramTest::start() output
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Nov 3, 2020
1 parent d3a3a75 commit 15bec93
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions program-test/src/lib.rs
Expand Up @@ -387,6 +387,14 @@ impl Default for ProgramTest {
}
}

// Values returned by `ProgramTest::start`
pub struct StartOutputs {
pub banks_client: BanksClient,
pub payer: Keypair,
pub recent_blockhash: Hash,
pub rent: Rent,
}

impl ProgramTest {
pub fn new(
program_name: &str,
Expand Down Expand Up @@ -536,7 +544,7 @@ impl ProgramTest {
///
/// Returns a `BanksClient` interface into the test environment as well as a payer `Keypair`
/// with SOL for sending transactions
pub async fn start(self) -> (BanksClient, Keypair, Hash) {
pub async fn start(self) -> StartOutputs {
{
use std::sync::Once;
static ONCE: Once = Once::new();
Expand All @@ -555,7 +563,8 @@ impl ProgramTest {
bootstrap_validator_stake_lamports,
);
let mut genesis_config = gci.genesis_config;
genesis_config.rent = Rent::default();
let rent = Rent::default();
genesis_config.rent = rent;
genesis_config.fee_rate_governor =
solana_program::fee_calculator::FeeRateGovernor::default();
let payer = gci.mint_keypair;
Expand Down Expand Up @@ -607,6 +616,11 @@ impl ProgramTest {
.unwrap_or_else(|err| panic!("Failed to start banks client: {}", err));

let recent_blockhash = banks_client.get_recent_blockhash().await.unwrap();
(banks_client, payer, recent_blockhash)
StartOutputs {
banks_client,
payer,
recent_blockhash,
rent,
}
}
}

0 comments on commit 15bec93

Please sign in to comment.