Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(swamp): cover v1 blobs in swamp tests #3908

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
vgonkivs marked this conversation as resolved.
Show resolved Hide resolved
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