Skip to content

Commit

Permalink
test: versioned constant getters (#2915)
Browse files Browse the repository at this point in the history
## Context

During a 1:1 w/ @evan-forbes , we noticed that the versioned constant
getters don't have any unit tests.
  • Loading branch information
rootulp authored Dec 9, 2023
1 parent ce1c6cd commit 14db3df
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pkg/appconsts/versioned_consts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package appconsts_test

import (
"fmt"
"testing"

"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"
)

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},
{version: testground.Version, want: testground.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},
{version: testground.Version, want: testground.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)
})
}
}

0 comments on commit 14db3df

Please sign in to comment.