From 496ef2361454b1bbdbad7035b19c2e48897a5d42 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 8 Dec 2023 15:46:30 -0500 Subject: [PATCH 1/2] test: versioned constants --- pkg/appconsts/versioned_consts_test.go | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 pkg/appconsts/versioned_consts_test.go diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go new file mode 100644 index 0000000000..6a1e5f5592 --- /dev/null +++ b/pkg/appconsts/versioned_consts_test.go @@ -0,0 +1,48 @@ +package appconsts_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/celestiaorg/celestia-app/pkg/appconsts" + v1 "github.com/celestiaorg/celestia-app/pkg/appconsts/v1" + v2 "github.com/celestiaorg/celestia-app/pkg/appconsts/v2" +) + +func TestSubtreeRootThreshold(t *testing.T) { + type testCase struct { + version uint64 + want int + } + testCases := []testCase{ + {version: v1.Version, want: v1.SubtreeRootThreshold}, + {version: v2.Version, want: v2.SubtreeRootThreshold}, + } + for _, tc := range testCases { + name := fmt.Sprintf("version %v", tc.version) + t.Run(name, func(t *testing.T) { + got := appconsts.SubtreeRootThreshold(tc.version) + assert.Equal(t, tc.want, got) + }) + } +} + +func TestSquareSizeUpperBound(t *testing.T) { + type testCase struct { + version uint64 + want int + } + testCases := []testCase{ + {version: v1.Version, want: v1.SquareSizeUpperBound}, + {version: v2.Version, want: v2.SquareSizeUpperBound}, + } + for _, tc := range testCases { + name := fmt.Sprintf("version %v", tc.version) + t.Run(name, func(t *testing.T) { + got := appconsts.SquareSizeUpperBound(tc.version) + assert.Equal(t, tc.want, got) + }) + } +} From df6bf08da2f354cfffb6da34166db8479a82fc52 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 8 Dec 2023 15:51:14 -0500 Subject: [PATCH 2/2] test: add test cases for testground version --- pkg/appconsts/versioned_consts_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go index 6a1e5f5592..811660d45c 100644 --- a/pkg/appconsts/versioned_consts_test.go +++ b/pkg/appconsts/versioned_consts_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/celestiaorg/celestia-app/pkg/appconsts" + "github.com/celestiaorg/celestia-app/pkg/appconsts/testground" v1 "github.com/celestiaorg/celestia-app/pkg/appconsts/v1" v2 "github.com/celestiaorg/celestia-app/pkg/appconsts/v2" ) @@ -19,6 +20,7 @@ func TestSubtreeRootThreshold(t *testing.T) { testCases := []testCase{ {version: v1.Version, want: v1.SubtreeRootThreshold}, {version: v2.Version, want: v2.SubtreeRootThreshold}, + {version: testground.Version, want: testground.SubtreeRootThreshold}, } for _, tc := range testCases { name := fmt.Sprintf("version %v", tc.version) @@ -37,6 +39,7 @@ func TestSquareSizeUpperBound(t *testing.T) { testCases := []testCase{ {version: v1.Version, want: v1.SquareSizeUpperBound}, {version: v2.Version, want: v2.SquareSizeUpperBound}, + {version: testground.Version, want: testground.SquareSizeUpperBound}, } for _, tc := range testCases { name := fmt.Sprintf("version %v", tc.version)