x/ibc: fix int overflow (#6171)

x/ibc/07-tendermint/types/test_utils.go: Calculate and use
machine-dependent maxInt instead of causing int overflow by
passing math.MaxInt64.

Closes: #6130
This commit is contained in:
Alessio Treglia 2020-05-08 03:11:29 +01:00 committed by GitHub
parent fe9fe87693
commit c8c47786da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1,7 +1,6 @@
package types
import (
"math"
"time"
"github.com/tendermint/tendermint/crypto/tmhash"
@ -9,6 +8,8 @@ import (
"github.com/tendermint/tendermint/version"
)
const maxInt = int(^uint(0) >> 1)
// Copied unimported test functions from tmtypes to use them here
func MakeBlockID(hash []byte, partSetSize int, partSetHash []byte) tmtypes.BlockID {
return tmtypes.BlockID{
@ -28,7 +29,7 @@ func CreateTestHeader(chainID string, height int64, timestamp time.Time, valSet
ChainID: chainID,
Height: height,
Time: timestamp,
LastBlockID: MakeBlockID(make([]byte, tmhash.Size), math.MaxInt64, make([]byte, tmhash.Size)),
LastBlockID: MakeBlockID(make([]byte, tmhash.Size), maxInt, make([]byte, tmhash.Size)),
LastCommitHash: tmhash.Sum([]byte("last_commit_hash")),
DataHash: tmhash.Sum([]byte("data_hash")),
ValidatorsHash: vsetHash,