Skip to content

Commit

Permalink
add select
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Jul 5, 2023
1 parent 0e8cc59 commit 41327fc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions share/eds/retriever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func BenchmarkBEFPValidation(b *testing.B) {
odsSize := []int{2, 4, 16, 32, 64, 128}
for _, size := range odsSize {
b.Run(fmt.Sprintf("ods size:%d", size), func(b *testing.B) {
b.ResetTimer()
b.StopTimer()
eds := edstest.RandByzantineEDS(t, size)
err := ipld.ImportEDS(ctx, eds, bServ)
Expand All @@ -192,6 +193,7 @@ func BenchmarkBEFPValidation(b *testing.B) {
b.StartTimer()

for i := 0; i < b.N; i++ {
b.ReportAllocs()
p := byzantine.CreateBadEncodingProof([]byte("hash"), uint64(h.Height()), errByz)
err = p.Validate(h)
require.NoError(b, err)
Expand All @@ -209,7 +211,6 @@ BenchmarkNewErrByzantineData/ods_size:64 340 3445544 ns/op 47670
BenchmarkNewErrByzantineData/ods_size:128 132 8740678 ns/op 11991093 B/op 136584 allocs/op
*/
func BenchmarkNewErrByzantineData(b *testing.B) {
RetrieveQuadrantTimeout = time.Millisecond * 500
odsSize := []int{2, 4, 16, 32, 64, 128}
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
Expand All @@ -225,8 +226,13 @@ func BenchmarkNewErrByzantineData(b *testing.B) {
h := headertest.ExtendedHeaderFromEDS(t, 1, eds)
ses, err := r.newSession(ctx, h.DAH)
require.NoError(t, err)
time.Sleep(RetrieveQuadrantTimeout * 2)
<-ses.Done()

select {
case <-ctx.Done():
b.Fatal(ctx.Err())
case <-ses.Done():
}

_, err = ses.Reconstruct(ctx)
assert.NoError(t, err)
var errByz *rsmt2d.ErrByzantineData
Expand Down

0 comments on commit 41327fc

Please sign in to comment.