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:
parent
fe9fe87693
commit
c8c47786da
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue