Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Program Test: Overwrite builtin when program ID matches#35242

Closed
buffalojoec wants to merge 1 commit into
solana-labs:masterfrom
buffalojoec:program-test-overwrite-builtin
Closed

Program Test: Overwrite builtin when program ID matches#35242
buffalojoec wants to merge 1 commit into
solana-labs:masterfrom
buffalojoec:program-test-overwrite-builtin

Conversation

@buffalojoec
Copy link
Copy Markdown
Contributor

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().

@buffalojoec buffalojoec requested a review from Lichtso February 19, 2024 16:00
@buffalojoec buffalojoec force-pushed the program-test-overwrite-builtin branch 4 times, most recently from 88f4208 to 462e053 Compare February 19, 2024 16:42
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 19, 2024

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     

@buffalojoec buffalojoec force-pushed the program-test-overwrite-builtin branch from 462e053 to 17a0400 Compare February 29, 2024 17:59
@2501babe 2501babe self-requested a review March 1, 2024 01:09
@2501babe
Copy link
Copy Markdown
Contributor

2501babe commented Mar 1, 2024

is there something is pr does than cant be accomplished by

let mut program_test = ProgramTest::default();
program_test.prefer_bpf(false);

@buffalojoec buffalojoec closed this Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants