ints: stricter numbers (#4939)

This commit is contained in:
Marko
2020-06-04 16:34:56 +02:00
committed by GitHub
parent 7c576f02ab
commit a88537bb88
56 changed files with 738 additions and 674 deletions
+1 -1
View File
@@ -354,7 +354,7 @@ func getBeginBlockValidatorInfo(block *types.Block, stateDB dbm.DB) (abci.LastCo
}
return abci.LastCommitInfo{
Round: int32(block.LastCommit.Round),
Round: block.LastCommit.Round,
Votes: voteInfos,
}, byzVals
}
+3 -3
View File
@@ -21,9 +21,9 @@ import (
)
var (
chainID = "execution_chain"
testPartSize = 65536
nTxsPerBlock = 10
chainID = "execution_chain"
testPartSize uint32 = 65536
nTxsPerBlock = 10
)
func TestApplyBlock(t *testing.T) {
+1 -1
View File
@@ -73,7 +73,7 @@ func makeValidCommit(
) (*types.Commit, error) {
sigs := make([]types.CommitSig, 0)
for i := 0; i < vals.Size(); i++ {
_, val := vals.GetByIndex(i)
_, val := vals.GetByIndex(int32(i))
vote, err := types.MakeVote(height, blockID, vals, privVals[val.Address.String()], chainID, time.Now())
if err != nil {
return nil, err
+1 -1
View File
@@ -371,7 +371,7 @@ func testProposerFreq(t *testing.T, caseNum int, valSet *types.ValidatorSet) {
// assert frequencies match expected (max off by 1)
for i, freq := range freqs {
_, val := valSet.GetByIndex(i)
_, val := valSet.GetByIndex(int32(i))
expectFreq := int(val.VotingPower) * runMult
gotFreq := freq
abs := int(math.Abs(float64(expectFreq - gotFreq)))
+1 -1
View File
@@ -321,7 +321,7 @@ func LoadValidators(db dbm.DB, height int64) (*types.ValidatorSet, error) {
),
)
}
valInfo2.ValidatorSet.IncrementProposerPriority(int(height - lastStoredHeight)) // mutate
valInfo2.ValidatorSet.IncrementProposerPriority(tmmath.SafeConvertInt32(height - lastStoredHeight)) // mutate
valInfo = valInfo2
}
+1 -1
View File
@@ -35,7 +35,7 @@ func TestTxFilter(t *testing.T) {
state, err := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc)
require.NoError(t, err)
f := sm.TxPreCheck(state)
f := sm.TxPreCheck(state) // current max size of a tx 1850
if tc.isErr {
assert.NotNil(t, f(tc.tx), "#%v", i)
} else {
+4 -3
View File
@@ -11,6 +11,7 @@ import (
"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/libs/log"
memmock "github.com/tendermint/tendermint/mempool/mock"
tmproto "github.com/tendermint/tendermint/proto/types"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/state/mocks"
"github.com/tendermint/tendermint/types"
@@ -185,7 +186,7 @@ func TestValidateBlockCommit(t *testing.T) {
Height: height,
Round: 0,
Timestamp: tmtime.Now(),
Type: types.PrecommitType,
Type: tmproto.PrecommitType,
BlockID: blockID,
}
err = badPrivVal.SignVote(chainID, goodVote)
@@ -240,9 +241,9 @@ func TestValidateBlockEvidence(t *testing.T) {
require.True(t, maxNumEvidence > 2)
evidence := make([]types.Evidence, 0)
// precisely the amount of allowed evidence
for i := uint32(0); i < maxNumEvidence; i++ {
for i := int32(0); uint32(i) < maxNumEvidence; i++ {
// make different evidence for each validator
addr, _ := state.Validators.GetByIndex(int(i))
addr, _ := state.Validators.GetByIndex(i)
evidence = append(evidence, types.NewMockEvidence(height, time.Now(), addr))
}