diff --git a/share/eds/retriever_no_race_test.go b/share/eds/retriever_no_race_test.go deleted file mode 100644 index 34c54b7d02..0000000000 --- a/share/eds/retriever_no_race_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// go:build !race - -package eds - -import ( - "context" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/celestiaorg/celestia-app/pkg/da" - "github.com/celestiaorg/celestia-app/pkg/wrapper" - "github.com/celestiaorg/nmt" - "github.com/celestiaorg/rsmt2d" - - "github.com/celestiaorg/celestia-node/share" - "github.com/celestiaorg/celestia-node/share/eds/byzantine" - "github.com/celestiaorg/celestia-node/share/ipld" - "github.com/celestiaorg/celestia-node/share/testing/edstest" -) - -func TestRetriever_ByzantineError(t *testing.T) { - const width = 8 - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) - defer cancel() - - bserv := ipld.NewMemBlockservice() - shares := edstest.RandEDS(t, width).Flattened() - _, err := ipld.ImportShares(ctx, shares, bserv) - require.NoError(t, err) - - // corrupt shares so that eds erasure coding does not match - copy(shares[14][share.NamespaceSize:], shares[15][share.NamespaceSize:]) - - // import corrupted eds - batchAdder := ipld.NewNmtNodeAdder(ctx, bserv, ipld.MaxSizeBatchOption(width*2)) - attackerEDS, err := rsmt2d.ImportExtendedDataSquare( - shares, - share.DefaultRSMT2DCodec(), - wrapper.NewConstructor(uint64(width), - nmt.NodeVisitor(batchAdder.Visit)), - ) - require.NoError(t, err) - err = batchAdder.Commit() - require.NoError(t, err) - - // ensure we rcv an error - dah, err := da.NewDataAvailabilityHeader(attackerEDS) - require.NoError(t, err) - r := NewRetriever(bserv) - _, err = r.Retrieve(ctx, &dah) - var errByz *byzantine.ErrByzantine - require.ErrorAs(t, err, &errByz) -} diff --git a/share/shwap/getter/retriever_test.go b/share/shwap/getter/retriever_test.go index 8d927a1541..2694b72330 100644 --- a/share/shwap/getter/retriever_test.go +++ b/share/shwap/getter/retriever_test.go @@ -2,6 +2,7 @@ package shwap_getter import ( "context" + "github.com/celestiaorg/celestia-node/share/eds/byzantine" "go.uber.org/atomic" "testing" "time" @@ -11,7 +12,6 @@ import ( "github.com/celestiaorg/celestia-node/header" "github.com/celestiaorg/celestia-node/share" - "github.com/celestiaorg/celestia-node/share/ipld" "github.com/celestiaorg/celestia-node/share/testing/edstest" ) @@ -22,8 +22,7 @@ func TestRetriever_Retrieve(t *testing.T) { store, bstore := edsBlockstore(t) exch := DummySessionExchange{bstore} getter := NewGetter(exch, bstore) - bServ := ipld.NewMemBlockservice() - r := newRetriever(bServ, getter) + r := newRetriever(getter) height := atomic.NewUint64(1) type test struct { @@ -63,6 +62,33 @@ func TestRetriever_Retrieve(t *testing.T) { } } +func TestRetriever_ByzantineError(t *testing.T) { + const width = 8 + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() + + store, bstore := edsBlockstore(t) + exch := DummySessionExchange{bstore} + getter := NewGetter(exch, bstore) + r := newRetriever(getter) + + eds := edstest.RandEDS(t, width) + shares := eds.Flattened() + // corrupt shares so that eds erasure coding does not match + copy(shares[14][share.NamespaceSize:], shares[15][share.NamespaceSize:]) + + // store corrupted eds + put(t, store, eds, 1) + + // ensure we rcv an error + root, err := share.NewRoot(eds) + require.NoError(t, err) + hdr := &header.ExtendedHeader{RawHeader: header.RawHeader{Height: 1}, DAH: root} + _, err = r.Retrieve(ctx, hdr) + var errByz *byzantine.ErrByzantine + require.ErrorAs(t, err, &errByz) +} + // //func TestRetriever_ByzantineError(t *testing.T) { // const width = 8