diff --git a/CHANGELOG.md b/CHANGELOG.md index bcdcf73020..f8157594ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,10 @@ FEATURES IMPROVEMENTS * export command now writes current validator set for Tendermint +* [tests] Application module tests now use a mock application FIXES * [lcd] Switch to bech32 for addresses on all human readable inputs and outputs -* [lcd] Switch to bech32 for addresses on all human readable inputs and outputs ## 0.18.0 diff --git a/examples/basecoin/app/app_test.go b/examples/basecoin/app/app_test.go index 521516d472..23bc531c03 100644 --- a/examples/basecoin/app/app_test.go +++ b/examples/basecoin/app/app_test.go @@ -19,12 +19,10 @@ import ( "github.com/tendermint/tmlibs/log" ) -var accName = "foobart" - func setGenesis(bapp *BasecoinApp, accs ...auth.BaseAccount) error { genaccs := make([]*types.GenesisAccount, len(accs)) for i, acc := range accs { - genaccs[i] = types.NewGenesisAccount(&types.AppAccount{acc, accName}) + genaccs[i] = types.NewGenesisAccount(&types.AppAccount{acc, "foobart"}) } genesisState := types.GenesisState{ diff --git a/x/auth/mock/auth_app_test.go b/x/auth/mock/auth_app_test.go index a3ff6710ee..641c8a3665 100644 --- a/x/auth/mock/auth_app_test.go +++ b/x/auth/mock/auth_app_test.go @@ -1,7 +1,6 @@ package mock import ( - "fmt" "testing" "github.com/stretchr/testify/assert" @@ -42,70 +41,55 @@ func getMockApp(t *testing.T) *App { } func TestMsgChangePubKey(t *testing.T) { - fmt.Println("wackydebugoutput TestMsgChangePubKey 0") mapp := getMockApp(t) // Construct some genesis bytes to reflect basecoin/types/AppAccount // Give 77 foocoin to the first key coins := sdk.Coins{{"foocoin", 77}} - fmt.Println("wackydebugoutput TestMsgChangePubKey 1") acc1 := &auth.BaseAccount{ Address: addr1, Coins: coins, } - fmt.Println("wackydebugoutput TestMsgChangePubKey 3") accs := []auth.Account{acc1} - fmt.Println("wackydebugoutput TestMsgChangePubKey 4") // Construct genesis state SetGenesis(mapp, accs) // A checkTx context (true) ctxCheck := mapp.BaseApp.NewContext(true, abci.Header{}) - fmt.Println("wackydebugoutput TestMsgChangePubKey 5") res1 := mapp.AccountMapper.GetAccount(ctxCheck, addr1) assert.Equal(t, acc1, res1.(*auth.BaseAccount)) // Run a CheckDeliver SignCheckDeliver(t, mapp.BaseApp, sendMsg1, []int64{0}, true, priv1) - fmt.Println("wackydebugoutput TestMsgChangePubKey 6") // Check balances CheckBalance(t, mapp, addr1, sdk.Coins{{"foocoin", 67}}) - fmt.Println("wackydebugoutput TestMsgChangePubKey 7") CheckBalance(t, mapp, addr2, sdk.Coins{{"foocoin", 10}}) - fmt.Println("wackydebugoutput TestMsgChangePubKey 8") changePubKeyMsg := auth.MsgChangeKey{ Address: addr1, NewPubKey: priv2.PubKey(), } - fmt.Println("wackydebugoutput TestMsgChangePubKey 10") ctxDeliver := mapp.BaseApp.NewContext(false, abci.Header{}) - fmt.Println("wackydebugoutput TestMsgChangePubKey 11") acc2 := mapp.AccountMapper.GetAccount(ctxDeliver, addr1) // send a MsgChangePubKey SignCheckDeliver(t, mapp.BaseApp, changePubKeyMsg, []int64{1}, true, priv1) - fmt.Println("wackydebugoutput TestMsgChangePubKey 12") acc2 = mapp.AccountMapper.GetAccount(ctxDeliver, addr1) assert.True(t, priv2.PubKey().Equals(acc2.GetPubKey())) // signing a SendMsg with the old privKey should be an auth error tx := GenTx(sendMsg1, []int64{2}, priv1) - fmt.Println("wackydebugoutput TestMsgChangePubKey 13") res := mapp.Deliver(tx) assert.Equal(t, sdk.ToABCICode(sdk.CodespaceRoot, sdk.CodeUnauthorized), res.Code, res.Log) // resigning the tx with the new correct priv key should work SignCheckDeliver(t, mapp.BaseApp, sendMsg1, []int64{2}, true, priv2) - fmt.Println("wackydebugoutput TestMsgChangePubKey 14") // Check balances CheckBalance(t, mapp, addr1, sdk.Coins{{"foocoin", 57}}) - fmt.Println("wackydebugoutput TestMsgChangePubKey 15") CheckBalance(t, mapp, addr2, sdk.Coins{{"foocoin", 20}}) - fmt.Println("wackydebugoutput TestMsgChangePubKey 16") }