Cleanup lines to fit within 72 characters

This commit is contained in:
Adrian Brink 2017-08-31 13:54:08 +02:00
parent 2a6e71a753
commit 8eda3efa28
No known key found for this signature in database
GPG Key ID: 5F00B6750045E653
2 changed files with 22 additions and 14 deletions

View File

@ -42,17 +42,18 @@ type State struct {
GenesisDoc *types.GenesisDoc GenesisDoc *types.GenesisDoc
ChainID string ChainID string
// updated at end of SetBlockAndValidators // Updated at end of SetBlockAndValidators
LastBlockHeight int // Genesis state has this set to 0. So, Block(H=0) does not exist. // Genesis state has this set to 0. So, Block(H=0) does not exist
LastBlockHeight int
LastBlockID types.BlockID LastBlockID types.BlockID
LastBlockTime time.Time LastBlockTime time.Time
Validators *types.ValidatorSet Validators *types.ValidatorSet
LastValidators *types.ValidatorSet // block.LastCommit validated against this // block.LastCommit validated against LastValidators
LastValidators *types.ValidatorSet
// AppHash is updated after Commit // AppHash is updated after Commit
AppHash []byte AppHash []byte
TxIndexer txindex.TxIndexer `json:"-"` // Transaction indexer. TxIndexer txindex.TxIndexer `json:"-"` // Transaction indexer
// When a block returns a validator set change via EndBlock, // When a block returns a validator set change via EndBlock,
// the change only applies to the next block. // the change only applies to the next block.
@ -224,7 +225,8 @@ func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader typ
nextValSet.IncrementAccum(1) nextValSet.IncrementAccum(1)
s.setBlockAndValidators(header.Height, s.setBlockAndValidators(header.Height,
types.BlockID{header.Hash(), blockPartsHeader}, header.Time, types.BlockID{header.Hash(), blockPartsHeader},
header.Time,
prevValSet, nextValSet) prevValSet, nextValSet)
} }
@ -258,7 +260,7 @@ func GetState(stateDB dbm.DB, genesisFile string) *State {
return state return state
} }
//-------------------------------------------------- //------------------------------------------------------------------------
// ABCIResponses retains the responses of the various ABCI calls during block processing. // ABCIResponses retains the responses of the various ABCI calls during block processing.
// It is persisted to disk before calling Commit. // It is persisted to disk before calling Commit.
@ -298,10 +300,11 @@ func (vi *ValidatorsInfo) Bytes() []byte {
return wire.BinaryBytes(*vi) return wire.BinaryBytes(*vi)
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------
// Genesis // Genesis
// MakeGenesisStateFromFile reads and unmarshals state from the given file. // MakeGenesisStateFromFile reads and unmarshals state from the given
// file.
// //
// Used during replay and in tests. // Used during replay and in tests.
func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) *State { func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) *State {

View File

@ -19,8 +19,8 @@ import (
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )
// setupTestCase does setup common to all test cases
func setupTestCase(t *testing.T) (func(t *testing.T), dbm.DB, *State) { func setupTestCase(t *testing.T) (func(t *testing.T), dbm.DB, *State) {
config := cfg.ResetTestRoot("state_") config := cfg.ResetTestRoot("state_")
stateDB := dbm.NewDB("state", config.DBBackend, config.DBDir()) stateDB := dbm.NewDB("state", config.DBBackend, config.DBDir())
state := GetState(stateDB, config.GenesisFile()) state := GetState(stateDB, config.GenesisFile())
@ -38,7 +38,8 @@ func TestStateCopy(t *testing.T) {
stateCopy := state.Copy() stateCopy := state.Copy()
assert.True(state.Equals(stateCopy), cmn.Fmt("expected state and its copy to be identical. got %v\n expected %v\n", stateCopy, state)) assert.True(state.Equals(stateCopy),
cmn.Fmt("exppppppected state and its copy to be identical. got %v\n expected %v\n", stateCopy, state))
stateCopy.LastBlockHeight++ stateCopy.LastBlockHeight++
assert.False(state.Equals(stateCopy), cmn.Fmt("expected states to be different. got same %v", state)) assert.False(state.Equals(stateCopy), cmn.Fmt("expected states to be different. got same %v", state))
} }
@ -51,7 +52,8 @@ func TestStateSaveLoad(t *testing.T) {
state.Save() state.Save()
loadedState := LoadState(stateDB) loadedState := LoadState(stateDB)
assert.True(state.Equals(loadedState), cmn.Fmt("expected state and its copy to be identical. got %v\n expected %v\n", loadedState, state)) assert.True(state.Equals(loadedState),
cmn.Fmt("expected state and its copy to be identical. got %v\n expected %v\n", loadedState, state))
} }
func TestABCIResponsesSaveLoad(t *testing.T) { func TestABCIResponsesSaveLoad(t *testing.T) {
@ -76,7 +78,8 @@ func TestABCIResponsesSaveLoad(t *testing.T) {
state.SaveABCIResponses(abciResponses) state.SaveABCIResponses(abciResponses)
abciResponses2 := state.LoadABCIResponses() abciResponses2 := state.LoadABCIResponses()
assert.Equal(abciResponses, abciResponses2, cmn.Fmt("ABCIResponses don't match: Got %v, Expected %v", abciResponses2, abciResponses)) assert.Equal(abciResponses, abciResponses2,
cmn.Fmt("ABCIResponses don't match: Got %v, Expected %v", abciResponses2, abciResponses))
} }
func TestValidatorSimpleSaveLoad(t *testing.T) { func TestValidatorSimpleSaveLoad(t *testing.T) {
@ -170,7 +173,9 @@ func TestValidatorChangesSaveLoad(t *testing.T) {
} }
} }
func makeHeaderPartsResponses(state *State, height int, pubkey crypto.PubKey) (*types.Header, types.PartSetHeader, *ABCIResponses) { func makeHeaderPartsResponses(state *State, height int,
pubkey crypto.PubKey) (*types.Header, types.PartSetHeader, *ABCIResponses) {
block := makeBlock(height, state) block := makeBlock(height, state)
_, val := state.Validators.GetByIndex(0) _, val := state.Validators.GetByIndex(0)
abciResponses := &ABCIResponses{ abciResponses := &ABCIResponses{