diff --git a/extendeddatacrossword_test.go b/extendeddatacrossword_test.go index 5b15465..d360f68 100644 --- a/extendeddatacrossword_test.go +++ b/extendeddatacrossword_test.go @@ -42,7 +42,7 @@ func TestRepairExtendedDataSquare(t *testing.T) { flattened[12], flattened[13] = nil, nil // Re-import the data square. - eds, err := ImportExtendedDataSquare(flattened, codec, NewDefaultTree) + eds, err := ImportExtendedDataSquare(flattened, codec, DefaultTreeName) if err != nil { t.Errorf("ImportExtendedDataSquare failed: %v", err) } @@ -67,7 +67,7 @@ func TestRepairExtendedDataSquare(t *testing.T) { flattened[12], flattened[13], flattened[14] = nil, nil, nil // Re-import the data square. - eds, err := ImportExtendedDataSquare(flattened, codec, NewDefaultTree) + eds, err := ImportExtendedDataSquare(flattened, codec, DefaultTreeName) if err != nil { t.Errorf("ImportExtendedDataSquare failed: %v", err) } @@ -237,7 +237,7 @@ func BenchmarkRepair(b *testing.B) { // Generate a new range original data square then extend it square := genRandDS(originalDataWidth, shareSize) - eds, err := ComputeExtendedDataSquare(square, codec, NewDefaultTree) + eds, err := ComputeExtendedDataSquare(square, codec, DefaultTreeName) if err != nil { b.Error(err) } @@ -275,7 +275,7 @@ func BenchmarkRepair(b *testing.B) { } // Re-import the data square. - eds, _ = ImportExtendedDataSquare(flattened, codec, NewDefaultTree) + eds, _ = ImportExtendedDataSquare(flattened, codec, DefaultTreeName) b.StartTimer() @@ -301,7 +301,7 @@ func createTestEds(codec Codec, shareSize int) *ExtendedDataSquare { eds, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, codec, NewDefaultTree) + }, codec, DefaultTreeName) if err != nil { panic(err) } @@ -443,10 +443,7 @@ func createTestEdsWithNMT(t *testing.T, codec Codec, shareSize, namespaceSize in shares[i] = bytes.Repeat([]byte{byte(shareValue)}, shareSize) } - treeConstructorFn, err := TreeFn("testing-tree") - require.NoError(t, err) - - eds, err := ComputeExtendedDataSquare(shares, codec, treeConstructorFn) + eds, err := ComputeExtendedDataSquare(shares, codec, "testing-tree") require.NoError(t, err) return eds diff --git a/extendeddatasquare.go b/extendeddatasquare.go index ec58197..99b6a75 100644 --- a/extendeddatasquare.go +++ b/extendeddatasquare.go @@ -43,17 +43,11 @@ func (eds *ExtendedDataSquare) UnmarshalJSON(b []byte) error { return err } - var treeConstructor TreeConstructorFn if aux.Tree == "" { aux.Tree = DefaultTreeName } - treeConstructor, err = TreeFn(aux.Tree) - if err != nil { - return err - } - - importedEds, err := ImportExtendedDataSquare(aux.DataSquare, codecs[aux.Codec], treeConstructor) + importedEds, err := ImportExtendedDataSquare(aux.DataSquare, codecs[aux.Codec], aux.Tree) if err != nil { return err } @@ -66,7 +60,7 @@ func (eds *ExtendedDataSquare) UnmarshalJSON(b []byte) error { func ComputeExtendedDataSquare( data [][]byte, codec Codec, - treeCreatorFn TreeConstructorFn, + treeName string, ) (*ExtendedDataSquare, error) { if len(data) > codec.MaxChunks() { return nil, errors.New("number of chunks exceeds the maximum") @@ -78,14 +72,14 @@ func ComputeExtendedDataSquare( return nil, err } - ds, err := newDataSquare(data, treeCreatorFn, uint(chunkSize)) + treeCreatorFn, err := TreeFn(treeName) if err != nil { return nil, err } - treeName := getTreeNameFromConstructorFn(treeCreatorFn) - if treeName == "" { - return nil, errors.New("tree name not found") + ds, err := newDataSquare(data, treeCreatorFn, uint(chunkSize)) + if err != nil { + return nil, err } eds := ExtendedDataSquare{dataSquare: ds, codec: codec, treeName: treeName} @@ -101,7 +95,7 @@ func ComputeExtendedDataSquare( func ImportExtendedDataSquare( data [][]byte, codec Codec, - treeCreatorFn TreeConstructorFn, + treeName string, ) (*ExtendedDataSquare, error) { if len(data) > 4*codec.MaxChunks() { return nil, errors.New("number of chunks exceeds the maximum") @@ -113,14 +107,14 @@ func ImportExtendedDataSquare( return nil, err } - ds, err := newDataSquare(data, treeCreatorFn, uint(chunkSize)) + treeCreatorFn, err := TreeFn(treeName) if err != nil { return nil, err } - treeName := getTreeNameFromConstructorFn(treeCreatorFn) - if treeName == "" { - return nil, errors.New("tree name not found") + ds, err := newDataSquare(data, treeCreatorFn, uint(chunkSize)) + if err != nil { + return nil, err } eds := ExtendedDataSquare{dataSquare: ds, codec: codec, treeName: treeName} @@ -254,7 +248,7 @@ func (eds *ExtendedDataSquare) erasureExtendCol(codec Codec, i uint) error { } func (eds *ExtendedDataSquare) deepCopy(codec Codec) (ExtendedDataSquare, error) { - imported, err := ImportExtendedDataSquare(eds.Flattened(), codec, eds.createTreeFn) + imported, err := ImportExtendedDataSquare(eds.Flattened(), codec, eds.treeName) return *imported, err } diff --git a/extendeddatasquare_test.go b/extendeddatasquare_test.go index 041aac4..f4fa3cb 100644 --- a/extendeddatasquare_test.go +++ b/extendeddatasquare_test.go @@ -3,6 +3,7 @@ package rsmt2d import ( "bytes" "crypto/rand" + _ "embed" "encoding/json" "fmt" "reflect" @@ -25,6 +26,9 @@ var ( fifteens = bytes.Repeat([]byte{15}, shareSize) ) +//go:embed testdata/edsCustomTree.json +var edsCustomTree []byte + func TestComputeExtendedDataSquare(t *testing.T) { codec := NewLeoRSCodec() @@ -59,7 +63,7 @@ func TestComputeExtendedDataSquare(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - result, err := ComputeExtendedDataSquare(tc.data, codec, NewDefaultTree) + result, err := ComputeExtendedDataSquare(tc.data, codec, DefaultTreeName) assert.NoError(t, err) assert.Equal(t, tc.want, result.squareRow) }) @@ -67,7 +71,7 @@ func TestComputeExtendedDataSquare(t *testing.T) { t.Run("returns an error if chunkSize is not a multiple of 64", func(t *testing.T) { chunk := bytes.Repeat([]byte{1}, 65) - _, err := ComputeExtendedDataSquare([][]byte{chunk}, NewLeoRSCodec(), NewDefaultTree) + _, err := ComputeExtendedDataSquare([][]byte{chunk}, NewLeoRSCodec(), DefaultTreeName) assert.Error(t, err) }) } @@ -75,101 +79,95 @@ func TestComputeExtendedDataSquare(t *testing.T) { func TestImportExtendedDataSquare(t *testing.T) { t.Run("is able to import an EDS", func(t *testing.T) { eds := createExampleEds(t, shareSize) - got, err := ImportExtendedDataSquare(eds.Flattened(), NewLeoRSCodec(), NewDefaultTree) + got, err := ImportExtendedDataSquare(eds.Flattened(), NewLeoRSCodec(), DefaultTreeName) assert.NoError(t, err) assert.Equal(t, eds.Flattened(), got.Flattened()) }) t.Run("returns an error if chunkSize is not a multiple of 64", func(t *testing.T) { chunk := bytes.Repeat([]byte{1}, 65) - _, err := ImportExtendedDataSquare([][]byte{chunk}, NewLeoRSCodec(), NewDefaultTree) + _, err := ImportExtendedDataSquare([][]byte{chunk}, NewLeoRSCodec(), DefaultTreeName) assert.Error(t, err) }) } func TestMarshalJSON(t *testing.T) { - codec := NewLeoRSCodec() - result, err := ComputeExtendedDataSquare([][]byte{ - ones, twos, - threes, fours, - }, codec, NewDefaultTree) - if err != nil { - panic(err) - } + original, err := ComputeExtendedDataSquare([][]byte{ones, twos, threes, fours}, NewLeoRSCodec(), DefaultTreeName) + require.NoError(t, err) - edsBytes, err := json.Marshal(result) - if err != nil { - t.Errorf("failed to marshal EDS: %v", err) - } + edsBytes, err := original.MarshalJSON() + require.NoError(t, err) - var eds ExtendedDataSquare - err = json.Unmarshal(edsBytes, &eds) - if err != nil { - t.Errorf("failed to marshal EDS: %v", err) - } - if !reflect.DeepEqual(result.squareRow, eds.squareRow) { - t.Errorf("eds not equal after json marshal/unmarshal") - } + var got ExtendedDataSquare + err = json.Unmarshal(edsBytes, &got) + require.NoError(t, err) + + assert.Equal(t, original.dataSquare.Flattened(), got.dataSquare.Flattened()) + assert.Equal(t, original.codec.Name(), got.codec.Name()) + assert.Equal(t, original.treeName, got.treeName) } -// TestUnmarshalJSON test the UnmarshalJSON function. func TestUnmarshalJSON(t *testing.T) { - treeName := "testing_unmarshalJSON_tree" - treeConstructorFn := sudoConstructorFn - err := RegisterTree(treeName, treeConstructorFn) - require.NoError(t, err) + t.Run("throws an error when unmarshaling an unregistered custom tree", func(t *testing.T) { + var eds ExtendedDataSquare + err := eds.UnmarshalJSON(edsCustomTree) - codec := NewLeoRSCodec() - result, err := ComputeExtendedDataSquare([][]byte{ - ones, twos, - threes, fours, - }, codec, treeConstructorFn) - if err != nil { - panic(err) + assert.Error(t, err) + assert.Contains(t, err.Error(), "custom-tree not registered yet") + }) + + type testCase struct { + name string + original *ExtendedDataSquare + want *ExtendedDataSquare + wantErr bool } - tests := []struct { - name string - malleate func() - expectedTreeName string - cleanUp func() - }{ + defaultEDS := exampleEds(t, DefaultTreeName) + + // The tree name is intentionally set to empty to test whether the + // Unmarshal process appropriately falls back to the default tree + defaultEDSWithoutTreeName := exampleEds(t, DefaultTreeName) + defaultEDSWithoutTreeName.treeName = "" + + customTreeName := "custom-tree" + err := RegisterTree(customTreeName, sudoConstructorFn) + require.NoError(t, err) + defer cleanUp(customTreeName) + customEDS := exampleEds(t, customTreeName) + + testCases := []testCase{ { - "Tree field exists", - func() {}, - treeName, - func() { - cleanUp(treeName) - }, + name: "can unmarshal the default EDS", + original: defaultEDS, + want: defaultEDS, + wantErr: false, }, { - "Tree field missing", - func() { - // clear the tree name value in the eds before marshal - result.treeName = "" - }, - DefaultTreeName, - func() {}, + name: "can unmarshal the default EDS even if tree name is removed", + original: defaultEDSWithoutTreeName, + want: defaultEDS, + wantErr: false, + }, + { + name: "can unmarshal an EDS with a custom tree", + original: customEDS, + want: customEDS, + wantErr: false, }, } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - test.malleate() - edsBytes, err := json.Marshal(result) - if err != nil { - t.Errorf("failed to marshal EDS: %v", err) - } - var eds ExtendedDataSquare - err = json.Unmarshal(edsBytes, &eds) - if err != nil { - t.Errorf("failed to unmarshal EDS: %v", err) - } - if !reflect.DeepEqual(result.squareRow, eds.squareRow) { - t.Errorf("eds not equal after json marshal/unmarshal") - } - require.Equal(t, test.expectedTreeName, eds.treeName) + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + edsBytes, err := json.Marshal(tc.original) + assert.NoError(t, err) - test.cleanUp() + var got ExtendedDataSquare + err = got.UnmarshalJSON(edsBytes) + assert.NoError(t, err) + + assert.Equal(t, tc.want.dataSquare.Flattened(), got.dataSquare.Flattened()) + assert.Equal(t, tc.want.codec.Name(), got.codec.Name()) + assert.Equal(t, tc.want.treeName, got.treeName) }) } } @@ -225,7 +223,7 @@ func TestImmutableRoots(t *testing.T) { result, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, codec, NewDefaultTree) + }, codec, DefaultTreeName) if err != nil { panic(err) } @@ -260,7 +258,7 @@ func TestEDSRowColImmutable(t *testing.T) { result, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, codec, NewDefaultTree) + }, codec, DefaultTreeName) if err != nil { panic(err) } @@ -283,7 +281,7 @@ func TestRowRoots(t *testing.T) { eds, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, NewLeoRSCodec(), NewDefaultTree) + }, NewLeoRSCodec(), DefaultTreeName) require.NoError(t, err) rowRoots, err := eds.RowRoots() @@ -295,7 +293,7 @@ func TestRowRoots(t *testing.T) { eds, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, NewLeoRSCodec(), NewDefaultTree) + }, NewLeoRSCodec(), DefaultTreeName) require.NoError(t, err) // set a cell to nil to make the EDS incomplete @@ -311,7 +309,7 @@ func TestColRoots(t *testing.T) { eds, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, NewLeoRSCodec(), NewDefaultTree) + }, NewLeoRSCodec(), DefaultTreeName) require.NoError(t, err) colRoots, err := eds.ColRoots() @@ -323,7 +321,7 @@ func TestColRoots(t *testing.T) { eds, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, NewLeoRSCodec(), NewDefaultTree) + }, NewLeoRSCodec(), DefaultTreeName) require.NoError(t, err) // set a cell to nil to make the EDS incomplete @@ -353,7 +351,7 @@ func BenchmarkExtensionEncoding(b *testing.B) { fmt.Sprintf("%s %dx%dx%d ODS", codecName, i, i, len(square[0])), func(b *testing.B) { for n := 0; n < b.N; n++ { - eds, err := ComputeExtendedDataSquare(square, codec, NewDefaultTree) + eds, err := ComputeExtendedDataSquare(square, codec, DefaultTreeName) if err != nil { b.Error(err) } @@ -380,7 +378,7 @@ func BenchmarkExtensionWithRoots(b *testing.B) { fmt.Sprintf("%s %dx%dx%d ODS", codecName, i, i, len(square[0])), func(b *testing.B) { for n := 0; n < b.N; n++ { - eds, err := ComputeExtendedDataSquare(square, codec, NewDefaultTree) + eds, err := ComputeExtendedDataSquare(square, codec, DefaultTreeName) if err != nil { b.Error(err) } @@ -459,7 +457,7 @@ func TestEquals(t *testing.T) { unequalChunkSize := createExampleEds(t, shareSize*2) - unequalEds, err := ComputeExtendedDataSquare([][]byte{ones}, NewLeoRSCodec(), NewDefaultTree) + unequalEds, err := ComputeExtendedDataSquare([][]byte{ones}, NewLeoRSCodec(), DefaultTreeName) require.NoError(t, err) testCases := []testCase{ @@ -494,7 +492,7 @@ func TestRoots(t *testing.T) { eds, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, NewLeoRSCodec(), NewDefaultTree) + }, NewLeoRSCodec(), DefaultTreeName) require.NoError(t, err) roots, err := eds.Roots() @@ -521,7 +519,7 @@ func TestRoots(t *testing.T) { eds, err := ComputeExtendedDataSquare([][]byte{ ones, twos, threes, fours, - }, NewLeoRSCodec(), NewDefaultTree) + }, NewLeoRSCodec(), DefaultTreeName) require.NoError(t, err) // set a cell to nil to make the EDS incomplete @@ -542,7 +540,13 @@ func createExampleEds(t *testing.T, chunkSize int) (eds *ExtendedDataSquare) { threes, fours, } - eds, err := ComputeExtendedDataSquare(ods, NewLeoRSCodec(), NewDefaultTree) + eds, err := ComputeExtendedDataSquare(ods, NewLeoRSCodec(), DefaultTreeName) + require.NoError(t, err) + return eds +} + +func exampleEds(t *testing.T, treeName string) *ExtendedDataSquare { + eds, err := ComputeExtendedDataSquare([][]byte{ones, twos, threes, fours}, NewLeoRSCodec(), treeName) require.NoError(t, err) return eds } diff --git a/rsmt2d_test.go b/rsmt2d_test.go index 417ee89..2561c7e 100644 --- a/rsmt2d_test.go +++ b/rsmt2d_test.go @@ -35,7 +35,7 @@ func TestEdsRepairRoundtripSimple(t *testing.T) { threes, fours, }, tt.codec, - rsmt2d.NewDefaultTree, + rsmt2d.DefaultTreeName, ) if err != nil { t.Errorf("ComputeExtendedDataSquare failed: %v", err) @@ -56,7 +56,7 @@ func TestEdsRepairRoundtripSimple(t *testing.T) { flattened[12], flattened[13] = nil, nil // Re-import the data square. - eds, err = rsmt2d.ImportExtendedDataSquare(flattened, tt.codec, rsmt2d.NewDefaultTree) + eds, err = rsmt2d.ImportExtendedDataSquare(flattened, tt.codec, rsmt2d.DefaultTreeName) if err != nil { t.Errorf("ImportExtendedDataSquare failed: %v", err) } @@ -97,7 +97,7 @@ func TestEdsRepairTwice(t *testing.T) { threes, fours, }, tt.codec, - rsmt2d.NewDefaultTree, + rsmt2d.DefaultTreeName, ) if err != nil { t.Errorf("ComputeExtendedDataSquare failed: %v", err) @@ -120,7 +120,7 @@ func TestEdsRepairTwice(t *testing.T) { flattened[12], flattened[13] = nil, nil // Re-import the data square. - eds, err = rsmt2d.ImportExtendedDataSquare(flattened, tt.codec, rsmt2d.NewDefaultTree) + eds, err = rsmt2d.ImportExtendedDataSquare(flattened, tt.codec, rsmt2d.DefaultTreeName) if err != nil { t.Errorf("ImportExtendedDataSquare failed: %v", err) } @@ -139,7 +139,7 @@ func TestEdsRepairTwice(t *testing.T) { copy(flattened[1], missing) // Re-import the data square. - eds, err = rsmt2d.ImportExtendedDataSquare(flattened, tt.codec, rsmt2d.NewDefaultTree) + eds, err = rsmt2d.ImportExtendedDataSquare(flattened, tt.codec, rsmt2d.DefaultTreeName) if err != nil { t.Errorf("ImportExtendedDataSquare failed: %v", err) } @@ -205,7 +205,7 @@ func createExampleEds(t *testing.T, chunkSize int) (eds *rsmt2d.ExtendedDataSqua threes, fours, } - eds, err := rsmt2d.ComputeExtendedDataSquare(ods, rsmt2d.NewLeoRSCodec(), rsmt2d.NewDefaultTree) + eds, err := rsmt2d.ComputeExtendedDataSquare(ods, rsmt2d.NewLeoRSCodec(), rsmt2d.DefaultTreeName) require.NoError(t, err) return eds } diff --git a/testdata/edsCustomTree.json b/testdata/edsCustomTree.json new file mode 100644 index 0000000..c6a23e3 --- /dev/null +++ b/testdata/edsCustomTree.json @@ -0,0 +1,22 @@ +{ + "data_square": [ + "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=", + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ=", + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg=", + "Dw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8=", + "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=", + "CwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsL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FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU=", + "CAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg=" + ], + "codec": "Leopard", + "tree": "custom-tree" +} diff --git a/tree.go b/tree.go index 4523469..1980f15 100644 --- a/tree.go +++ b/tree.go @@ -2,7 +2,6 @@ package rsmt2d import ( "fmt" - "reflect" "sync" ) @@ -57,30 +56,3 @@ func TreeFn(treeName string) (TreeConstructorFn, error) { func removeTreeFn(treeName string) { treeFns.Delete(treeName) } - -// Get the tree name by the tree constructor function from the global map registry -// TODO: this code is temporary until all breaking changes is handle here: https://github.com/celestiaorg/rsmt2d/pull/278 -func getTreeNameFromConstructorFn(treeConstructor TreeConstructorFn) string { - key := "" - treeFns.Range(func(k, v interface{}) bool { - keyString, ok := k.(string) - if !ok { - // continue checking other key, value - return true - } - treeFn, ok := v.(TreeConstructorFn) - if !ok { - // continue checking other key, value - return true - } - - if reflect.DeepEqual(reflect.ValueOf(treeFn), reflect.ValueOf(treeConstructor)) { - key = keyString - return false - } - - return true - }) - - return key -} diff --git a/tree_test.go b/tree_test.go index b5fadc3..5fddf52 100644 --- a/tree_test.go +++ b/tree_test.go @@ -107,89 +107,6 @@ func TestTreeFn(t *testing.T) { } } -// TestGetTreeNameFromConstructorFn tests the GetTreeNameFromConstructorFn -// function which fetches tree name by it corresponding tree constructor function. -// -// TODO: When we handle all the breaking changes track in this PR: https://github.com/celestiaorg/rsmt2d/pull/278, should remove this test -func TestGetTreeNameFromConstructorFn(t *testing.T) { - treeName := "testing_get_tree_name_tree" - treeConstructorFn := sudoConstructorFn - invalidTreeName := struct{}{} - invalidCaseTreeName := "invalid_case_tree" - invalidTreeConstructorFn := "invalid constructor fn" - - tests := []struct { - name string - treeName string - treeFn TreeConstructorFn - malleate func() - expectGetKey bool - }{ - // The tree name is successfully fetched. - { - "get successfully", - treeName, - treeConstructorFn, - func() { - err := RegisterTree(treeName, treeConstructorFn) - require.NoError(t, err) - }, - true, - }, - // Unable to fetch an unregistered tree name. - { - "get unregisted tree name", - "unregisted_tree_name", - nil, - func() {}, - false, - }, - // Value (tree constructor function) from the global map iteration is an invalid - // value that cannot be type asserted into TreeConstructorFn type. - { - "get invalid interface value", - "", - nil, - func() { - // Seems like this case has low probability of happening - // since all register has been done through RegisterTree func - // which have strict type check as argument. - treeFns.Store(invalidCaseTreeName, invalidTreeConstructorFn) - }, - false, - }, - // Key (tree name) from the global map iteration is an invalid value that cannot - // be type asserted into string type. - { - "get invalid interface key", - "", - nil, - func() { - // Seems like this case has low probability of happening - // since all register has been done through RegisterTree func - // which have strict type check as argument. - treeFns.Store(invalidTreeName, treeConstructorFn) - }, - false, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - test.malleate() - - key := getTreeNameFromConstructorFn(test.treeFn) - if !test.expectGetKey { - require.Equal(t, key, "") - } else { - require.Equal(t, test.treeName, key) - } - }) - - cleanUp(test.treeName) - } -} - // Avoid duplicate with default_tree treeConstructorFn // registered during init. func sudoConstructorFn(_ Axis, _ uint) Tree {