mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-18 21:26:20 +00:00
types: remove panic from block methods (#7501)
This commit is contained in:
+10
-5
@@ -316,14 +316,16 @@ func TestCreateProposalBlock(t *testing.T) {
|
||||
)
|
||||
|
||||
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
|
||||
block, _ := blockExec.CreateProposalBlock(
|
||||
block, _, err := blockExec.CreateProposalBlock(
|
||||
height,
|
||||
state, commit,
|
||||
proposerAddr,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// check that the part set does not exceed the maximum block size
|
||||
partSet := block.MakePartSet(partSize)
|
||||
partSet, err := block.MakePartSet(partSize)
|
||||
require.NoError(t, err)
|
||||
assert.Less(t, partSet.ByteSize(), int64(maxBytes))
|
||||
|
||||
partSetFromHeader := types.NewPartSetFromHeader(partSet.Header())
|
||||
@@ -387,18 +389,20 @@ func TestMaxTxsProposalBlockSize(t *testing.T) {
|
||||
)
|
||||
|
||||
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
|
||||
block, _ := blockExec.CreateProposalBlock(
|
||||
block, _, err := blockExec.CreateProposalBlock(
|
||||
height,
|
||||
state, commit,
|
||||
proposerAddr,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
pb, err := block.ToProto()
|
||||
require.NoError(t, err)
|
||||
assert.Less(t, int64(pb.Size()), maxBytes)
|
||||
|
||||
// check that the part set does not exceed the maximum block size
|
||||
partSet := block.MakePartSet(partSize)
|
||||
partSet, err := block.MakePartSet(partSize)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, partSet.ByteSize(), int64(pb.Size()))
|
||||
}
|
||||
|
||||
@@ -494,11 +498,12 @@ func TestMaxProposalBlockSize(t *testing.T) {
|
||||
commit.Signatures = append(commit.Signatures, cs)
|
||||
}
|
||||
|
||||
block, partSet := blockExec.CreateProposalBlock(
|
||||
block, partSet, err := blockExec.CreateProposalBlock(
|
||||
math.MaxInt64,
|
||||
state, commit,
|
||||
proposerAddr,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// this ensures that the header is at max size
|
||||
block.Header.Time = timestamp
|
||||
|
||||
Reference in New Issue
Block a user