Skip to content

Commit

Permalink
add test cases for genesis (#112)
Browse files Browse the repository at this point in the history
increase coverage to 100%
  • Loading branch information
zsystm authored and leeren committed Oct 15, 2024
1 parent c2dcd55 commit 5190351
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 5190351

Please sign in to comment.