Skip to content

Commit

Permalink
test(swamp): cover v1 blobs in swamp tests (#3908)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs authored Nov 1, 2024
1 parent 46882c4 commit 0733c8d
Showing 1 changed file with 35 additions and 22 deletions.
57 changes: 35 additions & 22 deletions nodebuilder/tests/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ func TestBlobModule(t *testing.T) {
fullClient := getAdminClient(ctx, fullNode, t)
lightClient := getAdminClient(ctx, lightNode, t)

address, err := fullClient.State.AccountAddress(ctx)
require.NoError(t, err)
v1Blob, err := libshare.NewV1Blob(
libshare.MustNewV0Namespace(bytes.Repeat([]byte{5}, libshare.NamespaceVersionZeroIDSize)),
[]byte("test data"),
address.Bytes(),
)
require.NoError(t, err)

v1, err := convert(v1Blob)
require.NoError(t, err)
blobs = append(blobs, v1)

height, err := fullClient.Blob.Submit(ctx, blobs, state.NewTxConfig())
require.NoError(t, err)

Expand All @@ -72,32 +85,42 @@ func TestBlobModule(t *testing.T) {
doFn func(t *testing.T)
}{
{
name: "Get",
name: "GetV0",
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].Commitment, blob1.Commitment)
assert.Equal(t, blobs[0].Commitment, blob1.Commitment)
assert.Equal(t, blobs[0].Data(), blob1.Data())
assert.Nil(t, blob1.Signer())
},
},
{
name: "GetAll",
name: "GetAllV0",
doFn: func(t *testing.T) {
// https://github.com/celestiaorg/celestia-node/issues/2915
time.Sleep(time.Second)
newBlobs, err := fullClient.Blob.GetAll(ctx, height, []libshare.Namespace{blobs[0].Namespace()})
require.NoError(t, err)
require.Len(t, newBlobs, len(libBlobs0))
require.True(t, bytes.Equal(blobs[0].Commitment, newBlobs[0].Commitment))
require.True(t, bytes.Equal(blobs[1].Commitment, newBlobs[1].Commitment))
assert.Len(t, newBlobs, len(libBlobs0))
assert.Equal(t, blobs[0].Commitment, newBlobs[0].Commitment)
assert.Equal(t, blobs[1].Commitment, newBlobs[1].Commitment)
assert.Nil(t, newBlobs[0].Signer())
assert.Nil(t, newBlobs[1].Signer())
},
},
{
name: "Get BlobV1",
doFn: func(t *testing.T) {
blobV1, err := fullClient.Blob.Get(ctx, height, v1.Namespace(), v1.Commitment)
require.NoError(t, err)
assert.Equal(t, libshare.ShareVersionOne, blobV1.ShareVersion())
assert.Equal(t, v1.Commitment, blobV1.Commitment)
assert.NotNil(t, blobV1.Signer())
assert.Equal(t, blobV1.Signer(), v1.Signer())

},
},
{
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 @@ -148,11 +171,6 @@ func TestBlobModule(t *testing.T) {
require.NoError(t, err)
require.Equal(t, b.Commitment, b0.Commitment)

// 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)

Expand All @@ -177,11 +195,6 @@ func TestBlobModule(t *testing.T) {
require.NoError(t, err)
require.Equal(t, blobs[0].Commitment, b0.Commitment)

// 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, h, blobs[0].Namespace(), blobs[0].Commitment)
require.NoError(t, err)

Expand Down

0 comments on commit 0733c8d

Please sign in to comment.