diff --git a/api/gateway/share_test.go b/api/gateway/share_test.go index aeccc9eb02..92b7a2c853 100644 --- a/api/gateway/share_test.go +++ b/api/gateway/share_test.go @@ -2,6 +2,9 @@ package gateway import ( "bytes" + _ "embed" + "encoding/base64" + "encoding/json" "testing" "github.com/stretchr/testify/assert" @@ -106,6 +109,7 @@ func Test_dataFromShares(t *testing.T) { assert.Error(t, err) return } + assert.NoError(t, err) assert.Equal(t, tc.want, got) }) } @@ -121,3 +125,35 @@ func padShare(share []byte) (paddedShare []byte) { func fillShare(share []byte, filler byte) (paddedShare []byte) { return append(share, bytes.Repeat([]byte{filler}, appconsts.ShareSize-len(share))...) } + +// sharesBase64JSON is the base64 encoded share data from Blockspace Race +// block height 559108 and namespace e8e5f679bf7116cb. +// +//go:embed "testdata/sharesBase64.json" +var sharesBase64JSON string + +// Test_dataFromSharesBSR reproduces an error that occurred when parsing shares +// on Blockspace Race block height 559108 namespace e8e5f679bf7116cb. +// +// https://github.com/celestiaorg/celestia-app/issues/1816 +func Test_dataFromSharesBSR(t *testing.T) { + var sharesBase64 []string + err := json.Unmarshal([]byte(sharesBase64JSON), &sharesBase64) + assert.NoError(t, err) + input := decode(sharesBase64) + + _, err = dataFromShares(input) + assert.NoError(t, err) +} + +// decode returns the raw shares from base64Encoded. +func decode(base64Encoded []string) (rawShares [][]byte) { + for _, share := range base64Encoded { + rawShare, err := base64.StdEncoding.DecodeString(share) + if err != nil { + panic(err) + } + rawShares = append(rawShares, rawShare) + } + return rawShares +} diff --git a/api/gateway/testdata/sharesBase64.json b/api/gateway/testdata/sharesBase64.json new file mode 100644 index 0000000000..e73d69f420 --- /dev/null +++ b/api/gateway/testdata/sharesBase64.json @@ -0,0 +1,8 @@ +[ + "6OX2eb9xFssBAAAEQwBIdZAtC1rH+hFrZ7F6azCBAAAAAAQreNqM02s323cAAGBVRFEjy9ENcVuibWqbtSpxGWWVuESNkhDZEYxlVZdqWd2bLhU1GkFHxzQRl6TVTpW4xQ5FXdJqyTnp1KX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q3EqseTZQ88S+W96xfj1F2f2eUU/y16CrHcfnvf3qdOtlkHXH86+pK5ybVAwW/Dr1pGCZzK5QtStHtb6sVFuQsig4ftZq1a46qUdT7m3hTwc=", + "6OX2eb9xFssAmWcHNW+S6eFdYXNeXPrbcmVS4Jo9zG/2vrsme05s1tMfW6ILLH3mEmueA9S8tka+O/zFxSXz6hqnZpm2qt393sGal79490QTjXrxzf8/EmueE9S8yDZJq+P6fi+8XnRW7n/yzPKX4gfLkLrsmOPuDYuKWus1iTXPBWrem89/37l9ejxT/s0cZYe5K+IN6h6qzF377/rp9dnvVBrmXSLWPDeoeclv12ZbWd3OC3QV35SZeZija9qGZcu/bmfJtjc4azH/YS+x5nlAzWO7/o/LxPc+X1DUE8299hUT5bYXWs6c+FBhWuPC6T5sPMuINc/rACAAAP//N89ueAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" +] diff --git a/go.mod b/go.mod index 25bb89586e..431a78f519 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/BurntSushi/toml v1.2.1 github.com/alecthomas/jsonschema v0.0.0-20200530073317-71f438968921 github.com/benbjohnson/clock v1.3.0 - github.com/celestiaorg/celestia-app v0.13.0 + github.com/celestiaorg/celestia-app v0.13.3 github.com/celestiaorg/go-fraud v0.1.0 github.com/celestiaorg/go-header v0.2.7 github.com/celestiaorg/go-libp2p-messenger v0.2.0 diff --git a/go.sum b/go.sum index 76ec8166ce..a7feaf83ab 100644 --- a/go.sum +++ b/go.sum @@ -340,8 +340,8 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7 github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= -github.com/celestiaorg/celestia-app v0.13.0 h1:NPOR1P98YCCv+E2I9TdqsO1/UnGyzTHW5CBhctWHaOY= -github.com/celestiaorg/celestia-app v0.13.0/go.mod h1:OcPBfWDyowJgoEQ89NB2LgLOm9LSwloCgCzdZKjmi78= +github.com/celestiaorg/celestia-app v0.13.3 h1:lJQLBzKALrKe0lLe3Gf8Si7+CF0eqRuNhjIjj7pM2fk= +github.com/celestiaorg/celestia-app v0.13.3/go.mod h1:OcPBfWDyowJgoEQ89NB2LgLOm9LSwloCgCzdZKjmi78= github.com/celestiaorg/celestia-core v1.15.0-tm-v0.34.23 h1:BHvn41IHOtvHeX1VZqO/xBFIHj93llcw9ZQfNxyVRlI= github.com/celestiaorg/celestia-core v1.15.0-tm-v0.34.23/go.mod h1:nL+vkAMKy/A8wWemWqMwBy4pOGWYYbboAVTEe3N5gIU= github.com/celestiaorg/cosmos-sdk v1.8.0-sdk-v0.46.7 h1:EADZy33ufskVIy6Rj6jbi3SOVCeYYo26zUi7iYx+QR0=