Skip to content

Commit

Permalink
test(share): add reconstrustrution test asserting that Full Node can …
Browse files Browse the repository at this point in the history
…reconstruct data from light nodes only
  • Loading branch information
Wondertan committed Jun 24, 2022
1 parent 35f865f commit 46bebf3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions service/share/full_availability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ package share
import (
"context"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"

"github.com/celestiaorg/celestia-node/ipld"
)

func TestSharesAvailable_Full(t *testing.T) {
Expand All @@ -29,3 +34,46 @@ func TestShareAvailableOverMocknet_Full(t *testing.T) {
err := nd.SharesAvailable(ctx, root)
assert.NoError(t, err)
}

func TestShareAvailable_FullOverLights(t *testing.T) {
ipld.RetrieveQuadrantTimeout = time.Millisecond * 200
DefaultSampleAmount = 20 // s

const (
origSquareSize = 16 // k
lightNodes = 69 // c
)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*60)
defer cancel()

net := NewTestDAGNet(ctx, t)
source, root := net.RandFullNode(origSquareSize) // make a source node, a.k.a bridge
full := net.FullNode() // make a full availability service which reconstructs data

lights := make([]*node, lightNodes)
for i := 0; i < len(lights); i++ {
light := net.LightNode()
net.Connect(light.ID(), full.ID())
net.Connect(light.ID(), source.ID())
lights[i] = light
}

errg, errCtx := errgroup.WithContext(ctx)
for i := 0; i < len(lights); i++ {
i := i
errg.Go(func() error {
return lights[i].SharesAvailable(errCtx, root)
})
}

err := errg.Wait()
require.NoError(t, err)

// ensure there is no connection between source and full nodes
// so that full reconstructs from the light nodes only
net.Disconnect(source.ID(), full.ID())

err = full.SharesAvailable(ctx, root)
assert.NoError(t, err)
}

0 comments on commit 46bebf3

Please sign in to comment.