Skip to content

Commit

Permalink
move retriever test to proper pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss committed Apr 1, 2024
1 parent eef869d commit 6394d37
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 58 deletions.
55 changes: 0 additions & 55 deletions share/eds/retriever_no_race_test.go

This file was deleted.

32 changes: 29 additions & 3 deletions share/shwap/getter/retriever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package shwap_getter

import (
"context"
"github.com/celestiaorg/celestia-node/share/eds/byzantine"
"go.uber.org/atomic"
"testing"
"time"
Expand All @@ -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"
)

Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6394d37

Please sign in to comment.