chore(all): modernized code with built-in min/max (#24124)
This commit is contained in:
parent
94068be123
commit
9acd7716dd
@ -175,11 +175,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
}
|
||||
// check block gas is always consumed
|
||||
baseGas := uint64(57504) // baseGas is the gas consumed before tx msg
|
||||
expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas)
|
||||
if expGasConsumed > uint64(simtestutil.DefaultConsensusParams.Block.MaxGas) {
|
||||
// capped by gasLimit
|
||||
expGasConsumed = uint64(simtestutil.DefaultConsensusParams.Block.MaxGas)
|
||||
}
|
||||
expGasConsumed := min(addUint64Saturating(tc.gasToConsume, baseGas), uint64(simtestutil.DefaultConsensusParams.Block.MaxGas))
|
||||
require.Equal(t, int(expGasConsumed), int(ctx.BlockGasMeter().GasConsumed()))
|
||||
// tx fee is always deducted
|
||||
require.Equal(t, int64(0), bankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount.Int64())
|
||||
|
||||
@ -35,11 +35,7 @@ func Paginate(numObjs, page, limit, defLimit int) (start, end int) {
|
||||
}
|
||||
|
||||
start = (page - 1) * limit
|
||||
end = limit + start
|
||||
|
||||
if end >= numObjs {
|
||||
end = numObjs
|
||||
}
|
||||
end = min(limit+start, numObjs)
|
||||
|
||||
if start >= numObjs {
|
||||
// page is out of bounds
|
||||
|
||||
@ -61,12 +61,7 @@ func newSplitAndApply(
|
||||
// split messages into slices of length chunkSize
|
||||
totalMessages := len(msgs)
|
||||
for i := 0; i < len(msgs); i += chunkSize {
|
||||
|
||||
sliceEnd := i + chunkSize
|
||||
if sliceEnd > totalMessages {
|
||||
sliceEnd = totalMessages
|
||||
}
|
||||
|
||||
sliceEnd := min(i+chunkSize, totalMessages)
|
||||
msgChunk := msgs[i:sliceEnd]
|
||||
if err := genOrBroadcastFn(clientCtx, fs, msgChunk...); err != nil {
|
||||
return err
|
||||
|
||||
@ -36,10 +36,7 @@ func TestPaginationProperty(t *testing.T) {
|
||||
CountTotal: false,
|
||||
Reverse: false,
|
||||
}
|
||||
end := offset + limit
|
||||
if end > uint64(len(tableModels)) {
|
||||
end = uint64(len(tableModels))
|
||||
}
|
||||
end := min(offset+limit, uint64(len(tableModels)))
|
||||
dest := reconstructedTableModels[offset:end]
|
||||
tableModelsIt := testTableModelIterator(tableModels, nil)
|
||||
_, err := Paginate(tableModelsIt, pageRequest, &dest)
|
||||
@ -65,12 +62,7 @@ func TestPaginationProperty(t *testing.T) {
|
||||
CountTotal: false,
|
||||
Reverse: false,
|
||||
}
|
||||
|
||||
end := start + limit
|
||||
if end > uint64(len(tableModels)) {
|
||||
end = uint64(len(tableModels))
|
||||
}
|
||||
|
||||
end := min(start+limit, uint64(len(tableModels)))
|
||||
dest := reconstructedTableModels[start:end]
|
||||
tableModelsIt := testTableModelIterator(tableModels, key)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user