Tests: Consistent resource/account struct tests#4669
Merged
michaeldiamant merged 5 commits intoOct 20, 2022
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4669 +/- ##
==========================================
+ Coverage 54.39% 54.40% +0.01%
==========================================
Files 403 407 +4
Lines 51921 52376 +455
==========================================
+ Hits 28240 28495 +255
- Misses 21300 21503 +203
+ Partials 2381 2378 -3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
algorandskiy
previously approved these changes
Oct 19, 2022
Contributor
algorandskiy
left a comment
There was a problem hiding this comment.
This is a great addition to the test suite
michaeldiamant
approved these changes
Oct 20, 2022
Contributor
michaeldiamant
left a comment
There was a problem hiding this comment.
@jasonpaulos Great improvement in correctness confidence here - thanks for the effort to devise + implement these tests! ☕
This was referenced Nov 5, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds new unit tests that use reflection to ensure the following sets of structs have consistent fields:
resourcesData(fromledger/accountdb.go) has all fields frombasics.AppLocalState,basics.AppParams,basics.AssetHolding, andbasics.AssetParamsbaseAccountData(fromledger/accountdb.go),ledercore.AccountData, andbasics.AccountDataall have consistent fields.When introducing a new account or resource field, it's all too easy to forgot to update all of these structs. These tests will fail if that's not done properly.
Additionally, this PR also adds
ledger/testing/randomAccounts_test.go, which ensures the distribution of random accounts fromRandomAccountsadheres to the following property: for every field inbasics.AccountData, there is high probability that at least one randomly generated account will have a nonzero value for that field, and another randomly generated account will have a zero value for that field. This property ensures thatRandomAccountsis aware of all fields inbasics.AccountData, and that each field may or may not be present in an account (with some exceptions).On the implementation side, I added to the existing reflection testing infrastructure from
data/basics/fields_test.goand moved it into its own package.Test Plan
New tests added.