From e2d23040a832f4e49ce22dcb807737591554dce5 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Thu, 21 Jun 2018 09:55:08 -0700 Subject: [PATCH] Merge PR #1325: Refactor Complete Setup to not take in a testing parameter * Refactor Complete Setup to not take in a testing parameter * Update changelog --- CHANGELOG.md | 1 + examples/democoin/x/cool/app_test.go | 3 ++- examples/democoin/x/pow/app_test.go | 3 ++- x/auth/mock/app.go | 8 ++------ x/auth/mock/auth_app_test.go | 3 ++- x/bank/app_test.go | 2 +- x/ibc/app_test.go | 5 +++-- x/slashing/app_test.go | 2 +- x/stake/app_test.go | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5edcaedcf8..9efa8c047d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ BREAKING CHANGES FEATURES * [gaiacli] You can now attach a simple text-only memo to any transaction, with the `--memo` flag +* [mockapp] CompleteSetup() no longer takes a testing parameter FIXES * \#1259 - fix bug where certain tests that could have a nil pointer in defer diff --git a/examples/democoin/x/cool/app_test.go b/examples/democoin/x/cool/app_test.go index eae3250e0b..abb048dcc5 100644 --- a/examples/democoin/x/cool/app_test.go +++ b/examples/democoin/x/cool/app_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" abci "github.com/tendermint/abci/types" crypto "github.com/tendermint/go-crypto" @@ -56,7 +57,7 @@ func getMockApp(t *testing.T) *mock.App { mapp.SetInitChainer(getInitChainer(mapp, keeper, "ice-cold")) - mapp.CompleteSetup(t, []*sdk.KVStoreKey{keyCool}) + require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyCool})) return mapp } diff --git a/examples/democoin/x/pow/app_test.go b/examples/democoin/x/pow/app_test.go index 0cfc890a06..2c1df6d6f3 100644 --- a/examples/democoin/x/pow/app_test.go +++ b/examples/democoin/x/pow/app_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -32,7 +33,7 @@ func getMockApp(t *testing.T) *mock.App { mapp.SetInitChainer(getInitChainer(mapp, keeper)) - mapp.CompleteSetup(t, []*sdk.KVStoreKey{keyPOW}) + require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyPOW})) return mapp } diff --git a/x/auth/mock/app.go b/x/auth/mock/app.go index 9530088076..8223733e05 100644 --- a/x/auth/mock/app.go +++ b/x/auth/mock/app.go @@ -1,11 +1,8 @@ package mock import ( - "testing" - "os" - "github.com/stretchr/testify/require" abci "github.com/tendermint/abci/types" dbm "github.com/tendermint/tmlibs/db" "github.com/tendermint/tmlibs/log" @@ -65,13 +62,12 @@ func NewApp() *App { } // complete the application setup after the routes have been registered -func (app *App) CompleteSetup(t *testing.T, newKeys []*sdk.KVStoreKey) { - +func (app *App) CompleteSetup(newKeys []*sdk.KVStoreKey) error { newKeys = append(newKeys, app.KeyMain) newKeys = append(newKeys, app.KeyAccount) app.MountStoresIAVL(newKeys...) err := app.LoadLatestVersion(app.KeyMain) - require.NoError(t, err) + return err } // custom logic for initialization diff --git a/x/auth/mock/auth_app_test.go b/x/auth/mock/auth_app_test.go index 9dfaba3b65..02c8eb454d 100644 --- a/x/auth/mock/auth_app_test.go +++ b/x/auth/mock/auth_app_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -36,7 +37,7 @@ func getMockApp(t *testing.T) *App { mapp.Router().AddRoute("bank", bank.NewHandler(coinKeeper)) mapp.Router().AddRoute("auth", auth.NewHandler(mapp.AccountMapper)) - mapp.CompleteSetup(t, []*sdk.KVStoreKey{}) + require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{})) return mapp } diff --git a/x/bank/app_test.go b/x/bank/app_test.go index b41ff42b09..8922eab44d 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -83,7 +83,7 @@ func getMockApp(t *testing.T) *mock.App { coinKeeper := NewKeeper(mapp.AccountMapper) mapp.Router().AddRoute("bank", NewHandler(coinKeeper)) - mapp.CompleteSetup(t, []*sdk.KVStoreKey{}) + require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{})) return mapp } diff --git a/x/ibc/app_test.go b/x/ibc/app_test.go index c546890100..a75a401f62 100644 --- a/x/ibc/app_test.go +++ b/x/ibc/app_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -24,7 +25,7 @@ func getMockApp(t *testing.T) *mock.App { coinKeeper := bank.NewKeeper(mapp.AccountMapper) mapp.Router().AddRoute("ibc", NewHandler(ibcMapper, coinKeeper)) - mapp.CompleteSetup(t, []*sdk.KVStoreKey{keyIBC}) + require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyIBC})) return mapp } @@ -70,7 +71,7 @@ func TestIBCMsgs(t *testing.T) { Sequence: 0, } - mock.SignCheckDeliver(t, mapp.BaseApp, transferMsg, []int64{0},[]int64{0}, true, priv1) + mock.SignCheckDeliver(t, mapp.BaseApp, transferMsg, []int64{0}, []int64{0}, true, priv1) mock.CheckBalance(t, mapp, addr1, emptyCoins) mock.SignCheckDeliver(t, mapp.BaseApp, transferMsg, []int64{0}, []int64{1}, false, priv1) mock.SignCheckDeliver(t, mapp.BaseApp, receiveMsg, []int64{0}, []int64{2}, true, priv1) diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 39b2819d25..9895c3ea2c 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -36,7 +36,7 @@ func getMockApp(t *testing.T) (*mock.App, stake.Keeper, Keeper) { mapp.SetEndBlocker(getEndBlocker(stakeKeeper)) mapp.SetInitChainer(getInitChainer(mapp, stakeKeeper)) - mapp.CompleteSetup(t, []*sdk.KVStoreKey{keyStake, keySlashing}) + require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyStake, keySlashing})) return mapp, stakeKeeper, keeper } diff --git a/x/stake/app_test.go b/x/stake/app_test.go index 023999c48c..c926a97523 100644 --- a/x/stake/app_test.go +++ b/x/stake/app_test.go @@ -42,7 +42,7 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) { mapp.SetEndBlocker(getEndBlocker(keeper)) mapp.SetInitChainer(getInitChainer(mapp, keeper)) - mapp.CompleteSetup(t, []*sdk.KVStoreKey{keyStake}) + require.NoError(t, mapp.CompleteSetup([]*sdk.KVStoreKey{keyStake})) return mapp, keeper }