Improve testcase, add comment

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

View File

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

View File

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