Skip to content

Commit 7eb5173

Browse files
committed
stability improvements
1 parent ae29303 commit 7eb5173

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

agreement/asyncVoteVerifier_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ func BenchmarkAsyncVerification(b *testing.B) {
8888
errProbs := []float32{0.0, 0.2, 0.8}
8989
for _, errProb := range errProbs {
9090
b.Run(fmt.Sprintf("errProb_%.3f_any_err", errProb), func(b *testing.B) {
91-
sendReceiveVoteVerifications(false, errProb, b.N, b.N, b)
91+
sendReceiveVoteVerifications(false, errProb, b.N/2, b.N/2, b)
9292
})
9393
if errProb > float32(0.0) {
9494
b.Run(fmt.Sprintf("errProb_%.3f_sig_err_only", errProb), func(b *testing.B) {
95-
sendReceiveVoteVerifications(true, errProb, b.N, b.N, b)
95+
sendReceiveVoteVerifications(true, errProb, b.N/2, b.N/2, b)
9696
})
9797
}
9898
}
@@ -134,6 +134,9 @@ func min(a, b int) int {
134134
}
135135

136136
func sendReceiveVoteVerifications(badSigOnly bool, errProb float32, count, eqCount int, tb testing.TB) {
137+
if count+eqCount < 10 {
138+
return
139+
}
137140
voteVerifier := MakeAsyncVoteVerifier(nil)
138141
defer voteVerifier.Quit()
139142

@@ -217,13 +220,15 @@ func generateTestVotes(onlyBadSigs bool, errChan chan<- error, count, eqCount in
217220
wg := sync.WaitGroup{}
218221
vg := makeTestVoteGenerator()
219222

223+
nextErrType := 0
220224
for c := 0; c < count; c++ {
221225
errType := 99
222226
if rand.Float32() < errProb {
223227
if onlyBadSigs {
224228
errType = 0
225229
} else {
226-
errType = rand.Intn(7)
230+
errType = nextErrType
231+
nextErrType = (nextErrType + 1) % (vg.voteOptions() - 1)
227232
}
228233
}
229234
v, err := vg.getTestVote(errType)
@@ -234,14 +239,16 @@ func generateTestVotes(onlyBadSigs bool, errChan chan<- error, count, eqCount in
234239
votes[v.id] = v
235240
}
236241

242+
nextErrType = 0
237243
vg.counter = 0
238244
for c := 0; c < eqCount; c++ {
239245
errType := 99
240246
if rand.Float32() < errProb {
241247
if onlyBadSigs {
242248
errType = 0
243249
} else {
244-
errType = rand.Intn(9)
250+
errType = nextErrType
251+
nextErrType = (nextErrType + 1) % (vg.voteEqOptions() - 1)
245252
}
246253
}
247254
v, err := vg.getTestEqVote(errType)
@@ -447,14 +454,14 @@ func (vg *testVoteGenerator) getTestEqVote(errType int) (v *unEqVoteTest, err er
447454

448455
switch errType {
449456
case 0:
450-
// check for same vote
451-
v = &unEqVoteTest{uev: &evSameVote, err: fmt.Errorf("error same vote"), id: c}
452-
453-
case 1:
454457
badSig := ev
455458
badSig.Sigs[0].Sig[0] = badSig.Sigs[0].Sig[0] + 1
456459
v = &unEqVoteTest{uev: &badSig, err: fmt.Errorf("error bad sig"), id: c}
457460

461+
case 1:
462+
// check for same vote
463+
v = &unEqVoteTest{uev: &evSameVote, err: fmt.Errorf("error same vote"), id: c}
464+
458465
case 2:
459466
noCred := ev
460467
noCred.Cred = committee.UnauthenticatedCredential{}

agreement/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func (l *testLedger) LookupAgreement(r basics.Round, a basics.Address) (basics.O
325325

326326
if r >= l.nextRound {
327327
err := fmt.Errorf("Lookup called on future round: %v >= %v! (this is probably a bug)", r, l.nextRound)
328-
panic(err)
328+
return basics.OnlineAccountData{}, err
329329
}
330330

331331
if l.maxNumBlocks != 0 && r+round(l.maxNumBlocks) < l.nextRound {

0 commit comments

Comments
 (0)