Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BankForks on tests - Part 2 #34234

Merged
merged 2 commits into from
Nov 29, 2023
Merged

Use BankForks on tests - Part 2 #34234

merged 2 commits into from
Nov 29, 2023

Conversation

LucasSte
Copy link
Contributor

Problem

In order for us to implement #34169 (remove WorkSlot from LoadedPrograms::extract), we need to make sure all tests create a BankFork and use a Bank instance that has been added to the fork.

Summary of Changes

This PR adds a few auxiliary functions to deal with BankForks and fixes some tests. This is the continuation of the work I started on #34206 .

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
Copy link

codecov bot commented Nov 27, 2023

Codecov Report

Merging #34234 (40b2fb1) into master (e832765) will increase coverage by 0.0%.
Report is 17 commits behind head on master.
The diff coverage is 95.7%.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #34234    +/-   ##
========================================
  Coverage    81.9%    81.9%            
========================================
  Files         819      819            
  Lines      219350   219426    +76     
========================================
+ Hits       179698   179802   +104     
+ Misses      39652    39624    -28     

@LucasSte LucasSte requested a review from pgarg66 November 27, 2023 21:44
@LucasSte LucasSte marked this pull request as ready for review November 27, 2023 21:44
@@ -977,6 +977,21 @@ impl Bank {
(bank_arc, bank_fork)
}

#[cfg(feature = "dev-context-only-utils")]
pub fn new_from_parent_with_bank_forks(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not add this to Bank as a constructor. This function is using public methods from Bank and BankForks. So it can be easily implemented as part of the tests.

The test code can carry this function as a utility function. We can copy the function to different test files (in case crate boundary is causing it to be inaccessible).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You nailed my problem. I did not want to repeat code between crates, so I guess this is the solution after all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we should avoid repeating the code. In this particular case, adding the constructor to Bank seems incorrect, since it's a test-only code. And, it's two lines of code that calls the public functions. So it seems ok to copy the function to tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I repeated the function. Let me know what you think.

@LucasSte LucasSte requested a review from pgarg66 November 29, 2023 13:28
@LucasSte LucasSte merged commit aeb4a34 into solana-labs:master Nov 29, 2023
32 checks passed
@LucasSte LucasSte deleted the fork-part-2 branch November 29, 2023 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants