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

x/gov/keeper: fix flaky TestPaginatedVotesQuery (backport #9223) #9225

Merged
merged 2 commits into from
Apr 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions x/gov/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,29 @@ func TestPaginatedVotesQuery(t *testing.T) {
app.GovKeeper.SetProposal(ctx, proposal)

votes := make([]types.Vote, 20)
rand := rand.New(rand.NewSource(time.Now().UnixNano()))
addr := make(sdk.AccAddress, 20)
random := rand.New(rand.NewSource(time.Now().UnixNano()))
addrMap := make(map[string]struct{})
genAddr := func() string {
addr := make(sdk.AccAddress, 20)
for {
random.Read(addr)
addrStr := addr.String()
if _, ok := addrMap[addrStr]; !ok {
addrMap[addrStr] = struct{}{}
return addrStr
}
}
}
for i := range votes {
rand.Read(addr)
vote := types.Vote{
ProposalId: proposal.ProposalId,
<<<<<<< HEAD
Voter: addr.String(),
Option: types.OptionYes,
=======
Voter: genAddr(),
Options: types.NewNonSplitVoteOption(types.OptionYes),
>>>>>>> 6ad84c506... x/gov/keeper: fix flaky TestPaginatedVotesQuery (#9223)
}
votes[i] = vote
app.GovKeeper.SetVote(ctx, vote)
Expand Down