mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 06:54:41 +00:00
+7
-5
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -386,7 +387,7 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func makeParams(blockBytes, blockGas, evidenceAge int64) types.ConsensusParams {
|
||||
func makeParams(blockBytes, blockGas int64, evidenceAge time.Duration) types.ConsensusParams {
|
||||
return types.ConsensusParams{
|
||||
BlockSize: types.BlockSize{
|
||||
MaxBytes: blockBytes,
|
||||
@@ -403,7 +404,8 @@ func pk() []byte {
|
||||
}
|
||||
|
||||
func TestApplyUpdates(t *testing.T) {
|
||||
initParams := makeParams(1, 2, 3)
|
||||
initParams := makeParams(1, 2, 3*time.Second)
|
||||
newMaxAge := 66 * time.Second
|
||||
|
||||
cases := [...]struct {
|
||||
init types.ConsensusParams
|
||||
@@ -419,14 +421,14 @@ func TestApplyUpdates(t *testing.T) {
|
||||
MaxGas: 55,
|
||||
},
|
||||
},
|
||||
makeParams(44, 55, 3)},
|
||||
makeParams(44, 55, 3*time.Second)},
|
||||
3: {initParams,
|
||||
abci.ConsensusParams{
|
||||
EvidenceParams: &abci.EvidenceParams{
|
||||
MaxAge: 66,
|
||||
MaxAge: &newMaxAge,
|
||||
},
|
||||
},
|
||||
makeParams(1, 2, 66)},
|
||||
makeParams(1, 2, 66*time.Second)},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
|
||||
+3
-5
@@ -168,13 +168,11 @@ func validateBlock(stateDB dbm.DB, state State, block *types.Block) error {
|
||||
// - it is internally consistent
|
||||
// - it was properly signed by the alleged equivocator
|
||||
func VerifyEvidence(stateDB dbm.DB, state State, evidence types.Evidence) error {
|
||||
height := state.LastBlockHeight
|
||||
|
||||
evidenceAge := height - evidence.Height()
|
||||
evidenceAge := state.LastBlockTime.Sub(evidence.Time())
|
||||
maxAge := state.ConsensusParams.EvidenceParams.MaxAge
|
||||
if evidenceAge > maxAge {
|
||||
return fmt.Errorf("Evidence from height %d is too old. Min height is %d",
|
||||
evidence.Height(), height-maxAge)
|
||||
return fmt.Errorf("Evidence from %v is too old. Expecting evidence no older than %v",
|
||||
evidence.Time(), state.LastBlockTime.Add(-maxAge))
|
||||
}
|
||||
|
||||
valset, err := LoadValidators(stateDB, evidence.Height())
|
||||
|
||||
Reference in New Issue
Block a user