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

Puts create_tmp_accounts_dir_for_tests() behind DCOU #34022

Conversation

brooksprumo
Copy link
Contributor

Problem

create_tmp_accounts_dir_for_tests() is used by tests to create a temp "accounts path" directory. But nothing is stopping a non-test from calling it...

Summary of Changes

...until now! Put it behind DCOU.

(and give the function some documentation too, for good measure)

@brooksprumo brooksprumo self-assigned this Nov 10, 2023
@brooksprumo brooksprumo force-pushed the snap/dcou/create_tmp_accounts_dir_for_tests branch from ec8b9e9 to e084ec9 Compare November 10, 2023 21:43
@brooksprumo brooksprumo marked this pull request as ready for review November 10, 2023 21:59
@brooksprumo brooksprumo requested a review from steviez November 10, 2023 21:59
@brooksprumo brooksprumo added the automerge Merge this Pull Request automatically once CI passes label Nov 10, 2023
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #34022 (e084ec9) into master (60d267a) will decrease coverage by 0.1%.
The diff coverage is 100.0%.

@@            Coverage Diff            @@
##           master   #34022     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         811      811             
  Lines      219427   219429      +2     
=========================================
- Hits       179813   179754     -59     
- Misses      39614    39675     +61     

Copy link
Contributor

@steviez steviez left a comment

Choose a reason for hiding this comment

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

One nit, but don't think it should block pushing the PR if you feel differently

@@ -1999,7 +1997,9 @@ pub fn verify_snapshot_archive(
) {
let temp_dir = tempfile::TempDir::new().unwrap();
let unpack_dir = temp_dir.path();
let unpack_account_dir = create_accounts_run_and_snapshot_dirs(unpack_dir).unwrap().0;
let unpack_account_dir = accounts_db::create_accounts_run_and_snapshot_dirs(unpack_dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I've found the tuple indexing to be kind of tricky sometimes. Doing the full de-structure is a bit more explicit:

let (unpack_account_dir, _snapshot_dir) = ...

This isn't perfect either as someone could still swap the order of the return types without breaking anything. I guess a struct with names fields, and unpacking by named field would be the only way to fully protect against this.

In any case, feel free to change or ignore; certainly don't want to punish the good deed of restricting access to the test only function

Copy link
Contributor

Choose a reason for hiding this comment

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

Lol, missed that you added auto-merge label. Like I said, I was fine pushing as-is anyways

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, tuples aren't the most explicit. I agree with you, I think destructing is probably the better call.

@mergify mergify bot merged commit 04e4efd into solana-labs:master Nov 11, 2023
33 checks passed
@brooksprumo brooksprumo deleted the snap/dcou/create_tmp_accounts_dir_for_tests branch November 11, 2023 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants