mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-08 04:50:16 +00:00
Fix all unit tests
This commit is contained in:
@@ -139,7 +139,7 @@ func TestFinalizeBlockDecidedLastCommit(t *testing.T) {
|
||||
}
|
||||
|
||||
// block for height 2
|
||||
block := makeBlock(state, 2, lastCommit.StripExtensions())
|
||||
block := makeBlock(state, 2, lastCommit.ToCommit())
|
||||
bps, err := block.MakePartSet(testPartSize)
|
||||
require.NoError(t, err)
|
||||
blockID := types.BlockID{Hash: block.Hash(), PartSetHeader: bps.Header()}
|
||||
|
||||
@@ -3,7 +3,7 @@ package types
|
||||
import (
|
||||
// it is ok to use math/rand here: we do not need a cryptographically secure random
|
||||
// number generator here and we can run the tests a bit faster
|
||||
"context"
|
||||
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"math"
|
||||
@@ -537,10 +537,8 @@ func TestVoteSetToExtendedCommit(t *testing.T) {
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
blockID := makeBlockIDRandom()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
valSet, vals := randValidatorPrivValSet(ctx, t, 10, 1)
|
||||
valSet, vals := RandValidatorSet(10, 1)
|
||||
var voteSet *VoteSet
|
||||
if testCase.includeExtension {
|
||||
voteSet = NewExtendedVoteSet("test_chain_id", 3, 1, tmproto.PrecommitType, valSet)
|
||||
@@ -548,7 +546,7 @@ func TestVoteSetToExtendedCommit(t *testing.T) {
|
||||
voteSet = NewVoteSet("test_chain_id", 3, 1, tmproto.PrecommitType, valSet)
|
||||
}
|
||||
for i := 0; i < len(vals); i++ {
|
||||
pubKey, err := vals[i].GetPubKey(ctx)
|
||||
pubKey, err := vals[i].GetPubKey()
|
||||
require.NoError(t, err)
|
||||
vote := &Vote{
|
||||
ValidatorAddress: pubKey.Address(),
|
||||
@@ -560,7 +558,7 @@ func TestVoteSetToExtendedCommit(t *testing.T) {
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
v := vote.ToProto()
|
||||
err = vals[i].SignVote(ctx, voteSet.ChainID(), v)
|
||||
err = vals[i].SignVote(voteSet.ChainID(), v)
|
||||
require.NoError(t, err)
|
||||
vote.Signature = v.Signature
|
||||
if testCase.includeExtension {
|
||||
|
||||
@@ -2,7 +2,6 @@ package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -511,11 +510,8 @@ func TestVoteSet_VoteExtensionsEnabled(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
height, round := int64(1), int32(0)
|
||||
valSet, privValidators := randValidatorPrivValSet(ctx, t, 5, 10)
|
||||
valSet, privValidators := RandValidatorSet(5, 10)
|
||||
var voteSet *VoteSet
|
||||
if tc.requireExtensions {
|
||||
voteSet = NewExtendedVoteSet("test_chain_id", height, round, tmproto.PrecommitType, valSet)
|
||||
@@ -525,7 +521,7 @@ func TestVoteSet_VoteExtensionsEnabled(t *testing.T) {
|
||||
|
||||
val0 := privValidators[0]
|
||||
|
||||
val0p, err := val0.GetPubKey(ctx)
|
||||
val0p, err := val0.GetPubKey()
|
||||
require.NoError(t, err)
|
||||
val0Addr := val0p.Address()
|
||||
blockHash := crypto.CRandBytes(32)
|
||||
@@ -542,7 +538,7 @@ func TestVoteSet_VoteExtensionsEnabled(t *testing.T) {
|
||||
BlockID: BlockID{blockHash, blockPartSetHeader},
|
||||
}
|
||||
v := vote.ToProto()
|
||||
err = val0.SignVote(ctx, voteSet.ChainID(), v)
|
||||
err = val0.SignVote(voteSet.ChainID(), v)
|
||||
require.NoError(t, err)
|
||||
vote.Signature = v.Signature
|
||||
|
||||
|
||||
@@ -240,9 +240,6 @@ func TestVoteExtension(t *testing.T) {
|
||||
privVal := NewMockPV()
|
||||
pk, err := privVal.GetPubKey()
|
||||
require.NoError(t, err)
|
||||
blk := Block{}
|
||||
ps, err := blk.MakePartSet(BlockPartSizeBytes)
|
||||
require.NoError(t, err)
|
||||
vote := &Vote{
|
||||
ValidatorAddress: pk.Address(),
|
||||
ValidatorIndex: 0,
|
||||
@@ -250,7 +247,7 @@ func TestVoteExtension(t *testing.T) {
|
||||
Round: round,
|
||||
Timestamp: tmtime.Now(),
|
||||
Type: tmproto.PrecommitType,
|
||||
BlockID: BlockID{blk.Hash(), ps.Header()},
|
||||
BlockID: makeBlockIDRandom(),
|
||||
}
|
||||
|
||||
v := vote.ToProto()
|
||||
|
||||
Reference in New Issue
Block a user