From 830ca369f1880f94dd6e27e438b605def37bcb41 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 20 Sep 2021 21:32:21 -0700 Subject: [PATCH] Add ProgramTest::add_builtin_program() This permits the unit testing of builtin programs in the ProgramTest environment --- program-test/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index b1ef58becd..92642745b7 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -715,6 +715,20 @@ impl ProgramTest { } } + /// Add a builtin program to the test environment. + /// + /// Note that builtin programs are responsible for their own `stable_log` output. + pub fn add_builtin_program( + &mut self, + program_name: &str, + program_id: Pubkey, + process_instruction: ProcessInstructionWithContext, + ) { + info!("\"{}\" builtin program", program_name); + self.builtins + .push(Builtin::new(program_name, program_id, process_instruction)); + } + fn setup_bank( &self, ) -> (