From fe8b2b78509d20fb5ebf454c79dbdbba9c41aee3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2020 03:12:17 +0000 Subject: [PATCH] Include Rent in ProgramTest::start() output (#13356) (cherry picked from commit c3d2d2134c93001566e1e56f691582f379b5ae55) Co-authored-by: Michael Vines --- program-test/src/lib.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 73434a9436..3bda2f9b26 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -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, @@ -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(); @@ -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; @@ -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, + } } }