Skip to content

Commit

Permalink
Merge PR #1325: Refactor Complete Setup to not take in a testing para…
Browse files Browse the repository at this point in the history
…meter

* Refactor Complete Setup to not take in a testing parameter
* Update changelog
  • Loading branch information
ValarDragon authored and cwgoes committed Jun 21, 2018
1 parent fb7e370 commit e2d2304
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/democoin/x/cool/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion examples/democoin/x/pow/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
8 changes: 2 additions & 6 deletions x/auth/mock/app.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion x/auth/mock/auth_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion x/bank/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 3 additions & 2 deletions x/ibc/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion x/stake/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e2d2304

Please sign in to comment.