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

Move `serde-snapshot dependent accounts-db tests #32671

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

pgarg66
Copy link
Contributor

@pgarg66 pgarg66 commented Jul 31, 2023

Problem

Some accounts-db unit tests depend on serde-snapshot. With runtime crate refactor, these tests ends up causing circular dependency between runtime and accounts-db crates.

Summary of Changes

Move the tests to serde-snapshot tests. This will allow these tests to have dependency on runtime as well as accounts-db.

Fixes #

@pgarg66 pgarg66 force-pushed the refactor-accounts-db-tests branch from 4d2852d to fc3b349 Compare July 31, 2023 23:27
@pgarg66 pgarg66 force-pushed the refactor-accounts-db-tests branch from fc3b349 to 46784ef Compare July 31, 2023 23:49
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #32671 (46784ef) into master (3dcb382) will increase coverage by 0.0%.
The diff coverage is 99.7%.

@@           Coverage Diff           @@
##           master   #32671   +/-   ##
=======================================
  Coverage    82.0%    82.0%           
=======================================
  Files         785      785           
  Lines      211100   211095    -5     
=======================================
+ Hits       173170   173180   +10     
+ Misses      37930    37915   -15     

@pgarg66 pgarg66 marked this pull request as ready for review August 4, 2023 15:18
@pgarg66 pgarg66 requested a review from brooksprumo August 4, 2023 15:18
Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

I'll audit the tests; maybe some of the functions/fields don't need to be made public, and instead the tests can be tweaked.

@brooksprumo brooksprumo self-requested a review August 4, 2023 15:24
Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Looks good overall.

For the code that was moved to runtime/src/serde_snapshot/tests.rs, can you point out any code that was altered from when it was in accounts_db.rs? I would assume "nothing", but maybe there's a few functions that needed to be made public?

Comment on lines -61 to -63
// a number of test cases in accounts_db use this
#[cfg(test)]
pub(crate) use tests::reconstruct_accounts_db_via_serialization;
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Comment on lines +1425 to +1426
pub accounts_delta_hashes: Mutex<HashMap<Slot, AccountsDeltaHash>>,
pub accounts_hashes: Mutex<HashMap<Slot, (AccountsHash, /*capitalization*/ u64)>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I can address these fields in a subsequent PR. For reference, I'll be using dev-context-only-utils, and it'll look something like this: #32718

@@ -9385,7 +9385,7 @@ impl AccountsDb {
});
}

fn print_count_and_status(&self, label: &str) {
pub fn print_count_and_status(&self, label: &str) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is the only non-test-exclusive function that was made public.

The function that calls it, print_account_stats(), is already public, and Bank has an entrypoint for it that's also public. That version is also mostly used in tests, except for one usage in ledger-tool.

I'm not sure tests need to print out this information, but it doesn't hurt. I imagine it was added initially for debugging.

Seems fine to make public.

@pgarg66
Copy link
Contributor Author

pgarg66 commented Aug 7, 2023

Looks good overall.

For the code that was moved to runtime/src/serde_snapshot/tests.rs, can you point out any code that was altered from when it was in accounts_db.rs? I would assume "nothing", but maybe there's a few functions that needed to be made public?

Yes, no other functional changes were made, besides making the tests compile in the new location. So some imports fixups and public function.

@pgarg66 pgarg66 requested a review from brooksprumo August 7, 2023 15:42
Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

lgtm

@pgarg66 pgarg66 merged commit 511cf28 into solana-labs:master Aug 7, 2023
@pgarg66 pgarg66 deleted the refactor-accounts-db-tests branch August 7, 2023 16:35
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