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 3 #34248

Merged
merged 2 commits into from
Dec 1, 2023
Merged

Use BankForks on tests - Part 3 #34248

merged 2 commits into from
Dec 1, 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 auxiliary functions to deal with BankForks and fixes tests in core. This is the continuation of the work I started on #34234

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Merging #34248 (a55a2a0) into master (e949ef9) will decrease coverage by 0.1%.
Report is 12 commits behind head on master.
The diff coverage is 92.6%.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #34248     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         819      819             
  Lines      219756   219741     -15     
=========================================
- Hits       180115   180035     -80     
- Misses      39641    39706     +65     

@LucasSte LucasSte marked this pull request as ready for review November 28, 2023 18:43
@LucasSte LucasSte marked this pull request as draft November 28, 2023 20:53
@LucasSte LucasSte marked this pull request as ready for review November 29, 2023 13:29
@@ -966,7 +966,7 @@ pub(super) enum RewardInterval {
}

impl Bank {
fn wrap_with_bank_forks_for_tests(self) -> (Arc<Self>, Arc<RwLock<BankForks>>) {
pub fn wrap_with_bank_forks_for_tests(self) -> (Arc<Self>, Arc<RwLock<BankForks>>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR seems like a good opportunity to move these public constructors/functions under DCOU. It'll be good cleanup for bank.rs.

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 use

#[cfg(feature = "dev-context-only-utils")]
as an example, where it has a separate impl block for all DCOU functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here in bank.rs, I can include this attribute in all functions whose name end with for_tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about define a new impl Bank {} and move all these test functions there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's going to be cleaner.

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 have refactored many test functions, but not all. Some are indirectly called in tests through many other auxiliary functions, which made further alterations too intricate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some functions with the for_test ending are not strictly under a test environment. program-test, for example, creates its own binary without a #[test] or a #[cfg(feature = "dev-context-only-utils")] attribute.

@LucasSte LucasSte requested a review from pgarg66 December 1, 2023 14:47
Copy link
Contributor

@pgarg66 pgarg66 left a comment

Choose a reason for hiding this comment

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

Looks great!

@LucasSte LucasSte merged commit b97b3dd into solana-labs:master Dec 1, 2023
45 checks passed
@LucasSte LucasSte deleted the fork-part-3 branch December 1, 2023 17:15
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