Skip to content

Commit

Permalink
Add stakingplus auth test
Browse files Browse the repository at this point in the history
  • Loading branch information
ulbqb committed Mar 7, 2024
1 parent 42c0c60 commit bd00435
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions x/foundation/stakingplus_authz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package foundation_test

import (
"testing"

"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/Finschia/finschia-sdk/x/foundation"
)

func TestCreateValidatorAuthorization(t *testing.T) {
validVal := "valid_val"
invalidVal := "invalid_val"

testCases := map[string]struct {
msg sdk.Msg
valid bool
accept bool
}{
"valid validator": {
msg: &stakingtypes.MsgCreateValidator{
ValidatorAddress: validVal,
},
valid: true,
accept: true,
},
"invalid validator": {
msg: &stakingtypes.MsgCreateValidator{
ValidatorAddress: invalidVal,
},
valid: false,
},
"msg mismatch": {
msg: &foundation.MsgVote{},
},
}

for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
authorization := &foundation.CreateValidatorAuthorization{
ValidatorAddress: validVal,
}

resp, err := authorization.Accept(sdk.Context{}, tc.msg)
if !tc.valid {
require.Error(t, err)
return
}
require.NoError(t, err)

require.Equal(t, tc.accept, resp.Accept)
})
}
}

0 comments on commit bd00435

Please sign in to comment.