Add mock.SignCheck, update testcase to assert error code

This commit is contained in:
Christopher Goes 2018-06-11 03:14:20 +02:00
parent f6a30afbf4
commit a4865ef6aa
No known key found for this signature in database
GPG Key ID: E828D98232D328D3
2 changed files with 10 additions and 3 deletions

View File

@ -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) {

View File

@ -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)
}