Skip to content

Commit

Permalink
chore: add unit test for bug
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes committed Dec 15, 2022
1 parent fdd9a36 commit c679765
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/shares/shares_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package shares

import (
"bytes"
"context"
"testing"
"time"
Expand All @@ -10,6 +11,7 @@ import (
"github.com/celestiaorg/rsmt2d"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
tmrand "github.com/tendermint/tendermint/libs/rand"
coretypes "github.com/tendermint/tendermint/types"
)

Expand Down Expand Up @@ -62,6 +64,32 @@ func TestMerge(t *testing.T) {
}
}

// TestPadFirstIndexedBlob ensures that we are adding padding to the first share
// instead of calculating the value.
func TestPadFirstIndexedBlob(t *testing.T) {
tx := tmrand.Bytes(300)
blob := tmrand.Bytes(300)
index := 100
indexedTx, err := coretypes.MarshalIndexWrapper(100, tx)
require.NoError(t, err)

bd := coretypes.Data{
Txs: []coretypes.Tx{indexedTx},
Blobs: []coretypes.Blob{
{NamespaceID: []byte{1, 2, 3, 4, 5, 6, 7, 8}, Data: blob, ShareVersion: appconsts.ShareVersionZero},
},
SquareSize: 64,
}

shares, err := Split(bd, true)
require.NoError(t, err)

resShare, err := shares[index].RawData()
require.NoError(t, err)

require.True(t, bytes.Contains(resShare, blob))
}

func TestFuzz_Merge(t *testing.T) {
t.Skip()
// run random shares through processCompactShares for a minute
Expand Down

0 comments on commit c679765

Please sign in to comment.