Improve testcase, add comment
This commit is contained in:
parent
2d2b57261c
commit
f6a30afbf4
|
@ -55,7 +55,7 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, pubkey crypto.PubKey,
|
|||
address := pubkey.Address()
|
||||
|
||||
// Local index, so counts blocks validator *should* have signed
|
||||
// Will use the 0-value default signing info if not present
|
||||
// Will use the 0-value default signing info if not present, except for start height
|
||||
signInfo, found := k.getValidatorSigningInfo(ctx, address)
|
||||
if !found {
|
||||
// If this validator has never been seen before, set the start height
|
||||
|
|
|
@ -144,12 +144,15 @@ func TestHandleNewValidator(t *testing.T) {
|
|||
// 1000 first blocks not a validator
|
||||
ctx = ctx.WithBlockHeight(1001)
|
||||
|
||||
// Now a validator
|
||||
// Now a validator, for two blocks
|
||||
keeper.handleValidatorSignature(ctx, val, true)
|
||||
ctx = ctx.WithBlockHeight(1002)
|
||||
keeper.handleValidatorSignature(ctx, val, false)
|
||||
|
||||
info, found := keeper.getValidatorSigningInfo(ctx, val.Address())
|
||||
require.True(t, found)
|
||||
require.Equal(t, int64(1001), info.StartHeight)
|
||||
require.Equal(t, int64(1), info.IndexOffset)
|
||||
require.Equal(t, int64(2), info.IndexOffset)
|
||||
require.Equal(t, int64(1), info.SignedBlocksCounter)
|
||||
require.Equal(t, int64(0), info.JailedUntil)
|
||||
|
||||
|
|
Loading…
Reference in New Issue