-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8136591
commit 50be6f2
Showing
6 changed files
with
140 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/suite" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
tmtime "github.com/tendermint/tendermint/types/time" | ||
|
||
"github.com/kava-labs/kava/app" | ||
"github.com/kava-labs/kava/x/community/keeper" | ||
"github.com/kava-labs/kava/x/community/types" | ||
) | ||
|
||
// Test suite used for all store tests | ||
type StoreTestSuite struct { | ||
suite.Suite | ||
|
||
App app.TestApp | ||
Ctx sdk.Context | ||
Keeper keeper.Keeper | ||
} | ||
|
||
// The default state used by each test | ||
func (suite *StoreTestSuite) SetupTest() { | ||
app.SetSDKConfig() | ||
suite.App = app.NewTestApp() | ||
suite.Ctx = suite.App.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()}) | ||
suite.Keeper = suite.App.GetCommunityKeeper() | ||
} | ||
|
||
func TestStoreTestSuite(t *testing.T) { | ||
suite.Run(t, new(StoreTestSuite)) | ||
} | ||
|
||
func (suite *StoreTestSuite) TestGetSetParams() { | ||
suite.Run("get params returns not found on empty store", func() { | ||
_, found := suite.Keeper.GetParams(suite.Ctx) | ||
suite.Require().False(found) | ||
}) | ||
|
||
suite.Run("set params cannot store invalid params", func() { | ||
invalid := types.Params{UpgradeTimeDisableInflation: time.Date(-1, 1, 1, 0, 0, 0, 0, time.UTC)} | ||
suite.Panics(func() { | ||
suite.Keeper.SetParams(suite.Ctx, invalid) | ||
}) | ||
}) | ||
|
||
suite.Run("get params returns stored params", func() { | ||
suite.Keeper.SetParams(suite.Ctx, types.DefaultParams()) | ||
|
||
storedParams, found := suite.Keeper.GetParams(suite.Ctx) | ||
suite.True(found) | ||
suite.Equal(types.DefaultParams(), storedParams) | ||
}) | ||
|
||
suite.Run("set overwrite previous value", func() { | ||
suite.Keeper.SetParams(suite.Ctx, types.DefaultParams()) | ||
|
||
params := types.NewParams(time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)) | ||
suite.Keeper.SetParams(suite.Ctx, params) | ||
|
||
storedParams, found := suite.Keeper.GetParams(suite.Ctx) | ||
suite.True(found) | ||
suite.NotEqual(params, types.DefaultParams()) | ||
suite.Equal(params, storedParams) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters