From a4865ef6aa8b1fd4db193171ec7bc6f40561fcf3 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Mon, 11 Jun 2018 03:14:20 +0200 Subject: [PATCH] Add mock.SignCheck, update testcase to assert error code --- x/auth/mock/simulate_block.go | 6 ++++++ x/slashing/app_test.go | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/x/auth/mock/simulate_block.go b/x/auth/mock/simulate_block.go index 72ec8411f..4db7bf630 100644 --- a/x/auth/mock/simulate_block.go +++ b/x/auth/mock/simulate_block.go @@ -52,6 +52,12 @@ func GenTx(msg sdk.Msg, seq []int64, priv ...crypto.PrivKeyEd25519) auth.StdTx { return auth.NewStdTx(msg, fee, sigs) } +func SignCheck(t *testing.T, app *baseapp.BaseApp, msg sdk.Msg, seq []int64, priv ...crypto.PrivKeyEd25519) sdk.Result { + tx := GenTx(msg, seq, priv...) + res := app.Check(tx) + return res +} + // simulate a block func SignCheckDeliver(t *testing.T, app *baseapp.BaseApp, msg sdk.Msg, seq []int64, expPass bool, priv ...crypto.PrivKeyEd25519) { diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index f0f1f7247..9253765d5 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -38,7 +38,7 @@ func getMockApp(t *testing.T) (*mock.App, stake.Keeper, Keeper) { keyStake := sdk.NewKVStoreKey("stake") keySlashing := sdk.NewKVStoreKey("slashing") coinKeeper := bank.NewKeeper(mapp.AccountMapper) - stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, coinKeeper, mapp.RegisterCodespace(DefaultCodespace)) + stakeKeeper := stake.NewKeeper(mapp.Cdc, keyStake, coinKeeper, mapp.RegisterCodespace(stake.DefaultCodespace)) keeper := NewKeeper(mapp.Cdc, keySlashing, stakeKeeper, mapp.RegisterCodespace(DefaultCodespace)) mapp.Router().AddRoute("stake", stake.NewHandler(stakeKeeper)) mapp.Router().AddRoute("slashing", NewHandler(keeper)) @@ -119,6 +119,7 @@ func TestSlashingMsgs(t *testing.T) { // no signing info yet checkValidatorSigningInfo(t, mapp, keeper, addr1, false) - // unrevoke should fail - mock.SignCheckDeliver(t, mapp.BaseApp, unrevokeMsg, []int64{1}, false, priv1) + // unrevoke should fail with unknown validator + res := mock.SignCheck(t, mapp.BaseApp, unrevokeMsg, []int64{1}, priv1) + require.Equal(t, sdk.ToABCICode(DefaultCodespace, CodeInvalidValidator), res.Code) }