Skip to content

Commit

Permalink
e2etest: update generateProofs for correctly support anonymous voting…
Browse files Browse the repository at this point in the history
… proofs
  • Loading branch information
mariajdab authored and altergui committed Apr 17, 2023
1 parent 584f9d9 commit 24324f9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/end2endtest/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,28 @@ func (t electionBase) generateProofs(root types.HexBytes, isAnonymousVoting bool
}
}()

apiClientMtx := &sync.Mutex{}
addNaccounts := func(accounts []*ethereum.SignKeys, wg *sync.WaitGroup) {
defer wg.Done()
log.Infof("generating %d voting proofs", len(accounts))
for _, acc := range accounts {
voterKey := acc.Address().Bytes()

if isAnonymousVoting {
apiClientMtx.Lock()
privKey := acc.PrivateKey()
if err := t.api.SetAccount(privKey.String()); err != nil {
apiClientMtx.Unlock()
log.Fatal(err)
return
}
voterKey = t.api.MyZkAddress().Bytes()
}

pr, err := t.api.CensusGenProof(root, voterKey)
if isAnonymousVoting {
apiClientMtx.Unlock()
}
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -242,7 +255,6 @@ func getCensusParticipantKey(voterAccount *ethereum.SignKeys, censusType string)
case vapi.CensusTypeWeighted:
key = voterAccount.Address().Bytes()
case vapi.CensusTypeZKWeighted:
fmt.Println("salito")
zkAddr, err := zk.AddressFromSignKeys(voterAccount)
if err != nil {
return nil, err
Expand Down

0 comments on commit 24324f9

Please sign in to comment.