Skip to content

Commit

Permalink
test: add keeper param tests (cosmos#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josumner authored Jul 16, 2021
1 parent 90b1433 commit 4967618
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions x/airdrop/keeper/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package keeper_test

import (
"testing"
"time"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/airdrop/types"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

var (
addr = sdk.AccAddress([]byte("addr________________"))
addrSet = sdk.AccAddress([]byte("addrSet_____________"))
)

type ParamsTestSuite struct {
suite.Suite

app *simapp.SimApp
ctx sdk.Context
}

func (s *ParamsTestSuite) SetupTest() {
app := simapp.Setup(false)
s.app = app
s.ctx = app.BaseApp.NewContext(false, tmproto.Header{
Time: time.Now(),
Height: 10,
})

s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(addr.String()))
}

func (s *ParamsTestSuite) TestGetAllowListClients() {
list := []string{addr.String()}
s.Require().Equal(s.app.AirdropKeeper.GetAllowListClients(s.ctx), list)
}

func (s *ParamsTestSuite) TestGetParams() {
p := types.Params{
AllowList: []string{addr.String()},
}
s.Require().Equal(s.app.AirdropKeeper.GetParams(s.ctx), p)
}

func (s *ParamsTestSuite) TestSetParams() {
p := types.Params{
AllowList: []string{addr.String(), addrSet.String()},
}
s.app.AirdropKeeper.SetParams(s.ctx, p)
s.Require().Equal(s.app.AirdropKeeper.GetParams(s.ctx), p)
}

func TestParamsTestSuite(t *testing.T) {
suite.Run(t, new(ParamsTestSuite))
}

0 comments on commit 4967618

Please sign in to comment.