-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
x/gov/keeper: fix flaky TestPaginatedVotesQuery #9223
Conversation
cc @odeke-em |
cc @AmauryM |
Codecov Report
@@ Coverage Diff @@
## master #9223 +/- ##
==========================================
+ Coverage 59.95% 60.03% +0.08%
==========================================
Files 595 595
Lines 37357 37352 -5
==========================================
+ Hits 22397 22425 +28
+ Misses 12974 12939 -35
- Partials 1986 1988 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @cuonglm, LGTM but we can simplify this code more.
When testing with -race, sometimes the random source generate the same string for consecutive calls, causing duplicated voter address. So the number of votes in DB is not 20. To fix this, we ensure unique addresses are generated, by using a map for tracking which one was produced, and skip the duplicated address and generated new one. Testing with: go test -race -v -count=1000 -run=TestPaginatedVotesQuery now passes. Updates #9010
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you Cuong!
When testing with -race, sometimes the random source generate the same string for consecutive calls, causing duplicated voter address. So the number of votes in DB is not 20. To fix this, we ensure unique addresses are generated, by using a map for tracking which one was produced, and skip the duplicated address and generated new one. Testing with: go test -race -v -count=1000 -run=TestPaginatedVotesQuery now passes. Updates #9010 (cherry picked from commit 6ad84c5) # Conflicts: # x/gov/keeper/querier_test.go
* x/gov/keeper: fix flaky TestPaginatedVotesQuery (#9223) When testing with -race, sometimes the random source generate the same string for consecutive calls, causing duplicated voter address. So the number of votes in DB is not 20. To fix this, we ensure unique addresses are generated, by using a map for tracking which one was produced, and skip the duplicated address and generated new one. Testing with: go test -race -v -count=1000 -run=TestPaginatedVotesQuery now passes. Updates #9010 (cherry picked from commit 6ad84c5) # Conflicts: # x/gov/keeper/querier_test.go * fi merge conflict Co-authored-by: Cuong Manh Le <cuong@orijtech.com> Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com>
Description
When testing with -race, sometimes the random source generate the same
string for consecutive calls, causing duplicated voter address. So the
number of votes in DB is not 20.
To fix this, we ensure unique addresses are generated, by using a map
for tracking which one was produced, and skip the duplicated address and
generated new one. Testing with:
now passes.
Updates #9010
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes