Add solana-program-test crate (bp #13324) (#13329)

* MockInvokeContext::get_programs() implementation

(cherry picked from commit 8acc47ee1b)

* start_local_server() now works with Banks > 0

(cherry picked from commit fa4bab4608)

* Add solana-program-test crate

(cherry picked from commit 52a292a75b)

* rebase

Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2020-11-01 05:43:43 +00:00
committed by GitHub
parent f2d929c12d
commit b6dc48da75
6 changed files with 671 additions and 15 deletions

View File

@@ -202,12 +202,12 @@ impl Logger for MockLogger {
}
}
#[derive(Debug)]
pub struct MockInvokeContext {
pub key: Pubkey,
pub logger: MockLogger,
pub bpf_compute_budget: BpfComputeBudget,
pub compute_meter: MockComputeMeter,
pub programs: Vec<(Pubkey, ProcessInstructionWithContext)>,
}
impl Default for MockInvokeContext {
fn default() -> Self {
@@ -218,6 +218,7 @@ impl Default for MockInvokeContext {
compute_meter: MockComputeMeter {
remaining: std::i64::MAX as u64,
},
programs: vec![],
}
}
}
@@ -238,7 +239,7 @@ impl InvokeContext for MockInvokeContext {
Ok(&self.key)
}
fn get_programs(&self) -> &[(Pubkey, ProcessInstructionWithContext)] {
&[]
&self.programs
}
fn get_logger(&self) -> Rc<RefCell<dyn Logger>> {
Rc::new(RefCell::new(self.logger.clone()))