Skip to content

Commit

Permalink
e2etest: hotfix raceDuringCommit
Browse files Browse the repository at this point in the history
PR #1102 was merged without realising it needed some changes
due to the merge of PR #1056 (one hour before)

this totally broke the `main` build, so here's a hotfix
  • Loading branch information
altergui committed Sep 20, 2023
1 parent 94d6149 commit f76c7d9
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions cmd/end2endtest/race.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (t *E2ERaceDuringCommit) Setup(api *apiclient.HTTPclient, c *config) error
ed.VoteType = vapi.VoteType{MaxVoteOverwrites: 1}
ed.Census = vapi.CensusTypeDescription{Type: vapi.CensusTypeWeighted}

if err := t.setupElection(ed); err != nil {
if err := t.setupElection(ed, t.config.nvotes); err != nil {
return err
}

Expand All @@ -52,21 +52,28 @@ func (*E2ERaceDuringCommit) Teardown() error {
}

func (t *E2ERaceDuringCommit) Run() error {
var vcount int
c := t.config

// Send the votes (parallelized)
startTime := time.Now()

log.Infof("enqueuing %d votes", len(t.voterAccounts))
log.Infof("enqueuing %d votes", t.config.nvotes)
votes := []*apiclient.VoteData{}
for i, acct := range t.voterAccounts {
votes = append(votes, &apiclient.VoteData{
ElectionID: t.election.ElectionID,
ProofMkTree: t.proofs[acct.Address().Hex()],
Choices: []int{i % 2},
VoterAccount: acct,
})
}

t.voters.Range(func(key, value any) bool {
if acctp, ok := value.(acctProof); ok {
votes = append(votes, &apiclient.VoteData{
ElectionID: t.election.ElectionID,
ProofMkTree: acctp.proof,
Choices: []int{vcount % 2},
VoterAccount: acctp.account,
})
vcount += 1
}
return true
})

errs := t.sendVotes(votes)
if len(errs) > 0 {
return fmt.Errorf("error in sendVotes %+v", errs)
Expand Down

0 comments on commit f76c7d9

Please sign in to comment.