Skip to content

Commit

Permalink
add test cases for genesis
Browse files Browse the repository at this point in the history
increase coverage to 100%
  • Loading branch information
zsystm committed Sep 19, 2024
1 parent ccd5834 commit 2f76911
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions client/x/evmstaking/types/genesis_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package types_test

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/piplabs/story/client/x/evmstaking/types"
)

var zeroVallidatorSweepIndex = &types.ValidatorSweepIndex{
NextValIndex: 0,
NextValDelIndex: 0,
}

func TestNewGenesisState(t *testing.T) {
t.Parallel()
tcs := []struct {
name string
params types.Params
expectedGenesisState *types.GenesisState
}{
{
name: "default params",
params: types.DefaultParams(),
expectedGenesisState: &types.GenesisState{
Params: types.DefaultParams(),
ValidatorSweepIndex: zeroVallidatorSweepIndex,
},
},
{
name: "custom params",
params: types.NewParams(
10,
20,
30,
),
expectedGenesisState: &types.GenesisState{
Params: types.NewParams(
10,
20,
30,
),
ValidatorSweepIndex: zeroVallidatorSweepIndex,
},
},
}

for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got := types.NewGenesisState(tc.params)
require.Equal(t, tc.expectedGenesisState, got)
})
}
}

func TestDefaultGenesisState(t *testing.T) {
t.Parallel()
expectedGenesisState := &types.GenesisState{
Params: types.DefaultParams(),
ValidatorSweepIndex: zeroVallidatorSweepIndex,
}
require.Equal(t, expectedGenesisState, types.DefaultGenesisState())
}

0 comments on commit 2f76911

Please sign in to comment.