IncrementAccum upon RPC /validators; Sanity checks and comments (#2808)

This commit is contained in:
Jae Kwon
2018-11-20 22:43:02 -08:00
committed by Anton Kaliaev
parent 1610a05cbd
commit 42592d9ae0
6 changed files with 60 additions and 10 deletions

View File

@ -3,9 +3,10 @@ package state
import (
"bytes"
"fmt"
"github.com/tendermint/tendermint/libs/log"
"testing"
"github.com/tendermint/tendermint/libs/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
@ -260,6 +261,27 @@ func TestOneValidatorChangesSaveLoad(t *testing.T) {
}
}
func TestStoreLoadValidatorsIncrementsAccum(t *testing.T) {
const valSetSize = 2
tearDown, stateDB, state := setupTestCase(t)
state.Validators = genValSet(valSetSize)
state.NextValidators = state.Validators.CopyIncrementAccum(1)
SaveState(stateDB, state)
defer tearDown(t)
nextHeight := state.LastBlockHeight + 1
v0, err := LoadValidators(stateDB, nextHeight)
assert.Nil(t, err)
acc0 := v0.Validators[0].Accum
v1, err := LoadValidators(stateDB, nextHeight+1)
assert.Nil(t, err)
acc1 := v1.Validators[0].Accum
assert.NotEqual(t, acc1, acc0, "expected Accum value to change between heights")
}
// TestValidatorChangesSaveLoad tests saving and loading a validator set with
// changes.
func TestManyValidatorChangesSaveLoad(t *testing.T) {