solana
solana copied to clipboard
Program Test: Overwrite builtin when program ID matches
Problem
In order to test the Core BPF version of a builtin program, we need to be able to overwrite the existing builtin with the Core BPF version using solana-program-test
.
Since ProgramTest::new()
will call Self::default()
, which automatically determines prefer_bpf
based on the SBF_OUT_DIR
, this will result in prefer_bpf = true
for the provided program. This will cause the provided Core BPF program to be overwritten by the existing builtin when the bank is set up.
Summary of Changes
Add a check to ProgramTest::new()
that will set prefer_bpf
to false
if the provided program ID matches that of a builtin. With prefer_bpf
set to false
, the Core BPF version of the program will replace the existing builtin during ProgramTest::start()
.
Note: @Lichtso I've rebased this commit on top of your recent PR #35233 since it requires the changes you've made to LoadedPrograms::assign_program()
.
Codecov Report
Attention: Patch coverage is 0%
with 3 lines
in your changes are missing coverage. Please review.
Project coverage is 81.7%. Comparing base (
6ee3bb9
) to head (17a0400
). Report is 21 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #35242 +/- ##
========================================
Coverage 81.7% 81.7%
========================================
Files 834 834
Lines 224299 224817 +518
========================================
+ Hits 183361 183843 +482
- Misses 40938 40974 +36
is there something is pr does than cant be accomplished by
let mut program_test = ProgramTest::default();
program_test.prefer_bpf(false);