Skip to content

Commit

Permalink
test: submit equal blobs in different pfbs
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Nov 10, 2023
1 parent 0ff12f9 commit 4e3eb86
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion nodebuilder/tests/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func TestBlobModule(t *testing.T) {
{
name: "Get",
doFn: func(t *testing.T) {
// https://github.com/celestiaorg/celestia-node/issues/2915
time.Sleep(time.Second)
blob1, err := fullClient.Blob.Get(ctx, height, blobs[0].Namespace(), blobs[0].Commitment)
require.NoError(t, err)
require.Equal(t, blobs[0], blob1)
Expand All @@ -81,6 +83,8 @@ func TestBlobModule(t *testing.T) {
{
name: "GetAll",
doFn: func(t *testing.T) {
// https://github.com/celestiaorg/celestia-node/issues/2915
time.Sleep(time.Second)
newBlobs, err := fullClient.Blob.GetAll(ctx, height, []share.Namespace{blobs[0].Namespace()})
require.NoError(t, err)
require.Len(t, newBlobs, len(appBlobs0))
Expand All @@ -91,6 +95,8 @@ func TestBlobModule(t *testing.T) {
{
name: "Included",
doFn: func(t *testing.T) {
// https://github.com/celestiaorg/celestia-node/issues/2915
time.Sleep(time.Second)
proof, err := fullClient.Blob.GetProof(ctx, height, blobs[0].Namespace(), blobs[0].Commitment)
require.NoError(t, err)

Expand Down Expand Up @@ -138,12 +144,16 @@ func TestBlobModule(t *testing.T) {
height, err := fullClient.Blob.Submit(ctx, []*blob.Blob{b, b}, nil)
require.NoError(t, err)

_, err = fullClient.Header.WaitForHeight(ctx, height)
require.NoError(t, err)

b0, err := fullClient.Blob.Get(ctx, height, b.Namespace(), b.Commitment)
require.NoError(t, err)
require.Equal(t, b, b0)

// give some time to store the data,
// otherwise the test will hang on the IPLD level.
// https://github.com/celestiaorg/celestia-node/issues/2915
time.Sleep(time.Second)

proof, err := fullClient.Blob.GetProof(ctx, height, b.Namespace(), b.Commitment)
Expand All @@ -154,12 +164,52 @@ func TestBlobModule(t *testing.T) {
require.True(t, included)
},
},
{
name: "Submit equal blobs in different PFBs",
doFn: func(t *testing.T) {
appBlob, err := blobtest.GenerateV0Blobs([]int{8, 4}, true)
require.NoError(t, err)
b, err := blob.NewBlob(
appBlob[0].ShareVersion,
append([]byte{appBlob[0].NamespaceVersion}, appBlob[0].NamespaceID...),
appBlob[0].Data,
)
require.NoError(t, err)

height0, err := fullClient.Blob.Submit(ctx, []*blob.Blob{b}, nil)
require.NoError(t, err)

height1, err := fullClient.Blob.Submit(ctx, []*blob.Blob{b}, nil)
require.NoError(t, err)

heights := []uint64{height0, height1}
for _, height := range heights {
_, err = fullClient.Header.WaitForHeight(ctx, height)
require.NoError(t, err)

b0, err := fullClient.Blob.Get(ctx, height, b.Namespace(), b.Commitment)
require.NoError(t, err)
require.Equal(t, b, b0)

// give some time to store the data,
// otherwise the test will hang on the IPLD level.
// https://github.com/celestiaorg/celestia-node/issues/2915
time.Sleep(time.Second)

proof, err := fullClient.Blob.GetProof(ctx, height, b.Namespace(), b.Commitment)
require.NoError(t, err)

included, err := fullClient.Blob.Included(ctx, height, b.Namespace(), proof, b.Commitment)
require.NoError(t, err)
require.True(t, included)
}
},
},
}

for _, tt := range test {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
tt.doFn(t)
})
}
Expand Down

0 comments on commit 4e3eb86

Please sign in to comment.