Skip to content

Commit

Permalink
tests(ipld): add new tests that reproduces #787 reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Jun 8, 2022
1 parent 4aa8148 commit 10a215a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ipld/retriever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,33 @@ func TestRetriever_ByzantineError(t *testing.T) {
var errByz *ErrByzantine
require.ErrorAs(t, err, &errByz)
}

// TestRetriever_MultipleRandQuadrants asserts that reconstruction succeeds
// when any three random quadrants requested.
func TestRetriever_MultipleRandQuadrants(t *testing.T) {
RetrieveQuadrantTimeout = time.Millisecond * 100
const squareSize = 32
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

bServ := mdutils.Bserv()
r := NewRetriever(bServ)

// generate EDS
shares := RandShares(t, squareSize*squareSize)
in, err := AddShares(ctx, shares, bServ)
require.NoError(t, err)

dah := da.NewDataAvailabilityHeader(in)
ses, err := r.newSession(ctx, &dah)
require.NoError(t, err)

// wait until two additional quadrants requested
// this reliably allows us to reproduce the issue
time.Sleep(RetrieveQuadrantTimeout * 2)
// then ensure we have enough shares for reconstruction for slow machines e.g. CI
<-ses.Done()

_, err = ses.Reconstruct()
assert.NoError(t, err)
}

0 comments on commit 10a215a

Please sign in to comment.