begin int64 to uint64 migration

This commit is contained in:
Marko Baricevic
2021-02-01 17:23:39 +01:00
parent fc71882f74
commit 0e477c014d
63 changed files with 731 additions and 753 deletions
+5 -5
View File
@@ -307,7 +307,7 @@ func MaxDataBytesNoEvidence(maxBytes int64, valsCount int) int64 {
// MakeBlock returns a new block with an empty header, except what can be
// computed from itself.
// It populates the same set of fields validated by ValidateBasic.
func MakeBlock(height int64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block {
func MakeBlock(height uint64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block {
block := &Block{
Header: Header{
Version: version.Consensus{Block: version.BlockProtocol, App: 0},
@@ -334,7 +334,7 @@ type Header struct {
// basic block info
Version version.Consensus `json:"version"`
ChainID string `json:"chain_id"`
Height int64 `json:"height"`
Height uint64 `json:"height"`
Time time.Time `json:"time"`
// prev block info
@@ -747,7 +747,7 @@ type Commit struct {
// ValidatorSet order.
// Any peer with a block can gossip signatures by index with a peer without
// recalculating the active ValidatorSet.
Height int64 `json:"height"`
Height uint64 `json:"height"`
Round int32 `json:"round"`
BlockID BlockID `json:"block_id"`
Signatures []CommitSig `json:"signatures"`
@@ -760,7 +760,7 @@ type Commit struct {
}
// NewCommit returns a new Commit.
func NewCommit(height int64, round int32, blockID BlockID, commitSigs []CommitSig) *Commit {
func NewCommit(height uint64, round int32, blockID BlockID, commitSigs []CommitSig) *Commit {
return &Commit{
Height: height,
Round: round,
@@ -825,7 +825,7 @@ func (commit *Commit) Type() byte {
// GetHeight returns height of the commit.
// Implements VoteSetReader.
func (commit *Commit) GetHeight() int64 {
func (commit *Commit) GetHeight() uint64 {
return commit.Height
}
+14 -33
View File
@@ -35,7 +35,7 @@ func TestMain(m *testing.M) {
func TestBlockAddEvidence(t *testing.T) {
txs := []Tx{Tx("foo"), Tx("bar")}
lastID := makeBlockIDRandom()
h := int64(3)
h := uint64(3)
voteSet, _, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
@@ -55,7 +55,7 @@ func TestBlockValidateBasic(t *testing.T) {
txs := []Tx{Tx("foo"), Tx("bar")}
lastID := makeBlockIDRandom()
h := int64(3)
h := uint64(3)
voteSet, valSet, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
@@ -71,7 +71,6 @@ func TestBlockValidateBasic(t *testing.T) {
}{
{"Make Block", func(blk *Block) {}, false},
{"Make Block w/ proposer Addr", func(blk *Block) { blk.ProposerAddress = valSet.GetProposer().Address }, false},
{"Negative Height", func(blk *Block) { blk.Height = -1 }, true},
{"Remove 1/2 the commits", func(blk *Block) {
blk.LastCommit.Signatures = commit.Signatures[:commit.Size()/2]
blk.LastCommit.hash = nil // clear hash or change wont be noticed
@@ -93,9 +92,6 @@ func TestBlockValidateBasic(t *testing.T) {
{"Missing LastCommit", func(blk *Block) {
blk.LastCommit = nil
}, true},
{"Invalid LastCommit", func(blk *Block) {
blk.LastCommit = NewCommit(-1, 0, *voteSet.maj23, nil)
}, true},
{"Invalid Evidence", func(blk *Block) {
emptyEv := &DuplicateVoteEvidence{}
blk.Evidence = EvidenceData{Evidence: []Evidence{emptyEv}}
@@ -117,13 +113,13 @@ func TestBlockValidateBasic(t *testing.T) {
func TestBlockHash(t *testing.T) {
assert.Nil(t, (*Block)(nil).Hash())
assert.Nil(t, MakeBlock(int64(3), []Tx{Tx("Hello World")}, nil, nil).Hash())
assert.Nil(t, MakeBlock(uint64(3), []Tx{Tx("Hello World")}, nil, nil).Hash())
}
func TestBlockMakePartSet(t *testing.T) {
assert.Nil(t, (*Block)(nil).MakePartSet(2))
partSet := MakeBlock(int64(3), []Tx{Tx("Hello World")}, nil, nil).MakePartSet(1024)
partSet := MakeBlock(uint64(3), []Tx{Tx("Hello World")}, nil, nil).MakePartSet(1024)
assert.NotNil(t, partSet)
assert.EqualValues(t, 1, partSet.Total())
}
@@ -132,7 +128,7 @@ func TestBlockMakePartSetWithEvidence(t *testing.T) {
assert.Nil(t, (*Block)(nil).MakePartSet(2))
lastID := makeBlockIDRandom()
h := int64(3)
h := uint64(3)
voteSet, _, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
@@ -150,7 +146,7 @@ func TestBlockHashesTo(t *testing.T) {
assert.False(t, (*Block)(nil).HashesTo(nil))
lastID := makeBlockIDRandom()
h := int64(3)
h := uint64(3)
voteSet, valSet, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
require.NoError(t, err)
@@ -166,7 +162,7 @@ func TestBlockHashesTo(t *testing.T) {
}
func TestBlockSize(t *testing.T) {
size := MakeBlock(int64(3), []Tx{Tx("Hello World")}, nil, nil).Size()
size := MakeBlock(uint64(3), []Tx{Tx("Hello World")}, nil, nil).Size()
if size <= 0 {
t.Fatal("Size of the block is zero or negative")
}
@@ -177,7 +173,7 @@ func TestBlockString(t *testing.T) {
assert.Equal(t, "nil-Block", (*Block)(nil).StringIndented(""))
assert.Equal(t, "nil-Block", (*Block)(nil).StringShort())
block := MakeBlock(int64(3), []Tx{Tx("Hello World")}, nil, nil)
block := MakeBlock(uint64(3), []Tx{Tx("Hello World")}, nil, nil)
assert.NotEqual(t, "nil-Block", block.String())
assert.NotEqual(t, "nil-Block", block.StringIndented(""))
assert.NotEqual(t, "nil-Block", block.StringShort())
@@ -228,7 +224,7 @@ func TestNilDataHashDoesntCrash(t *testing.T) {
func TestCommit(t *testing.T) {
lastID := makeBlockIDRandom()
h := int64(3)
h := uint64(3)
voteSet, _, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
require.NoError(t, err)
@@ -255,7 +251,6 @@ func TestCommitValidateBasic(t *testing.T) {
}{
{"Random Commit", func(com *Commit) {}, false},
{"Incorrect signature", func(com *Commit) { com.Signatures[0].Signature = []byte{0} }, false},
{"Incorrect height", func(com *Commit) { com.Height = int64(-100) }, true},
{"Incorrect round", func(com *Commit) { com.Round = -100 }, true},
}
for _, tc := range testCases {
@@ -440,7 +435,7 @@ func TestMaxHeaderBytes(t *testing.T) {
func randCommit(now time.Time) *Commit {
lastID := makeBlockIDRandom()
h := int64(3)
h := uint64(3)
voteSet, _, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, now)
if err != nil {
@@ -520,7 +515,7 @@ func TestBlockMaxDataBytesNoEvidence(t *testing.T) {
func TestCommitToVoteSet(t *testing.T) {
lastID := makeBlockIDRandom()
h := int64(3)
h := uint64(3)
voteSet, valSet, vals := randVoteSet(h-1, 1, tmproto.PrecommitType, 10, 1)
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
@@ -549,7 +544,7 @@ func TestCommitToVoteSetWithVotesForNilBlock(t *testing.T) {
blockID := makeBlockID([]byte("blockhash"), 1000, []byte("partshash"))
const (
height = int64(3)
height = uint64(3)
round = 0
)
@@ -642,7 +637,7 @@ func TestBlockIDValidateBasic(t *testing.T) {
}
func TestBlockProtoBuf(t *testing.T) {
h := tmrand.Int63()
h := uint64(tmrand.Int63())
c1 := randCommit(time.Now())
b1 := MakeBlock(h, []Tx{Tx([]byte{1})}, &Commit{Signatures: []CommitSig{}}, []Evidence{})
b1.ProposerAddress = tmrand.Bytes(crypto.AddressSize)
@@ -750,7 +745,7 @@ func TestEvidenceDataProtoBuf(t *testing.T) {
func makeRandHeader() Header {
chainID := "test"
t := time.Now()
height := tmrand.Int63()
height := uint64(tmrand.Int63())
randBytes := tmrand.Bytes(tmhash.Size)
randAddress := tmrand.Bytes(crypto.AddressSize)
h := Header{
@@ -971,15 +966,6 @@ func TestHeader_ValidateBasic(t *testing.T) {
},
true, "chainID is too long",
},
{
"invalid height (negative)",
Header{
Version: version.Consensus{Block: version.BlockProtocol},
ChainID: string(make([]byte, MaxChainIDLen)),
Height: -1,
},
true, "negative Height",
},
{
"invalid height (zero)",
Header{
@@ -1219,11 +1205,6 @@ func TestCommit_ValidateBasic(t *testing.T) {
expectErr bool
errString string
}{
{
"invalid height",
&Commit{Height: -1},
true, "negative Height",
},
{
"invalid round",
&Commit{Height: 1, Round: -1},
+3 -3
View File
@@ -6,8 +6,8 @@ type (
// ErrInvalidCommitHeight is returned when we encounter a commit with an
// unexpected height.
ErrInvalidCommitHeight struct {
Expected int64
Actual int64
Expected uint64
Actual uint64
}
// ErrInvalidCommitSignatures is returned when we encounter a commit where
@@ -18,7 +18,7 @@ type (
}
)
func NewErrInvalidCommitHeight(expected, actual int64) ErrInvalidCommitHeight {
func NewErrInvalidCommitHeight(expected, actual uint64) ErrInvalidCommitHeight {
return ErrInvalidCommitHeight{
Expected: expected,
Actual: actual,
+1 -1
View File
@@ -79,7 +79,7 @@ type EventDataNewBlockHeader struct {
type EventDataNewEvidence struct {
Evidence Evidence `json:"evidence"`
Height int64 `json:"height"`
Height uint64 `json:"height"`
}
// All txs fire EventDataTx
+8 -8
View File
@@ -23,7 +23,7 @@ type Evidence interface {
ABCI() []abci.Evidence // forms individual evidence to be sent to the application
Bytes() []byte // bytes which comprise the evidence
Hash() []byte // hash of the evidence
Height() int64 // height of the infraction
Height() uint64 // height of the infraction
String() string // string format of the evidence
Time() time.Time // time of the infraction
ValidateBasic() error // basic consistency check
@@ -103,7 +103,7 @@ func (dve *DuplicateVoteEvidence) Hash() []byte {
}
// Height returns the height of the infraction
func (dve *DuplicateVoteEvidence) Height() int64 {
func (dve *DuplicateVoteEvidence) Height() uint64 {
return dve.VoteA.Height
}
@@ -189,7 +189,7 @@ func DuplicateVoteEvidenceFromProto(pb *tmproto.DuplicateVoteEvidence) (*Duplica
// tendermint/docs/architecture/adr-047-handling-evidence-from-light-client.md
type LightClientAttackEvidence struct {
ConflictingBlock *LightBlock
CommonHeight int64
CommonHeight uint64
// abci specific information
ByzantineValidators []*Validator // validators in the validator set that misbehaved in creating the conflicting block
@@ -298,7 +298,7 @@ func (l *LightClientAttackEvidence) ConflictingHeaderIsInvalid(trustedHeader *He
// most commit signatures (captures the most byzantine validators) but anything greater than 1/3 is sufficient.
func (l *LightClientAttackEvidence) Hash() []byte {
buf := make([]byte, binary.MaxVarintLen64)
n := binary.PutVarint(buf, l.CommonHeight)
n := binary.PutUvarint(buf, l.CommonHeight)
bz := make([]byte, tmhash.Size+n)
copy(bz[:tmhash.Size-1], l.ConflictingBlock.Hash().Bytes())
copy(bz[tmhash.Size:], buf)
@@ -308,7 +308,7 @@ func (l *LightClientAttackEvidence) Hash() []byte {
// Height returns the last height at which the primary provider and witness provider had the same header.
// We use this as the height of the infraction rather than the actual conflicting header because we know
// that the malicious validators were bonded at this height which is important for evidence expiry
func (l *LightClientAttackEvidence) Height() int64 {
func (l *LightClientAttackEvidence) Height() uint64 {
return l.CommonHeight
}
@@ -539,13 +539,13 @@ func (err *ErrEvidenceOverflow) Error() string {
// unstable - use only for testing
// assumes the round to be 0 and the validator index to be 0
func NewMockDuplicateVoteEvidence(height int64, time time.Time, chainID string) *DuplicateVoteEvidence {
func NewMockDuplicateVoteEvidence(height uint64, time time.Time, chainID string) *DuplicateVoteEvidence {
val := NewMockPV()
return NewMockDuplicateVoteEvidenceWithValidator(height, time, val, chainID)
}
// assumes voting power to be 10 and validator to be the only one in the set
func NewMockDuplicateVoteEvidenceWithValidator(height int64, time time.Time,
func NewMockDuplicateVoteEvidenceWithValidator(height uint64, time time.Time,
pv PrivValidator, chainID string) *DuplicateVoteEvidence {
pubKey, _ := pv.GetPubKey()
val := NewValidator(pubKey, 10)
@@ -560,7 +560,7 @@ func NewMockDuplicateVoteEvidenceWithValidator(height int64, time time.Time,
return NewDuplicateVoteEvidence(voteA, voteB, time, NewValidatorSet([]*Validator{val}))
}
func makeMockVote(height int64, round, index int32, addr Address,
func makeMockVote(height uint64, round, index int32, addr Address,
blockID BlockID, time time.Time) *Vote {
return &Vote{
Type: tmproto.SignedMsgType(2),
+7 -8
View File
@@ -41,7 +41,7 @@ func randomDuplicateVoteEvidence(t *testing.T) *DuplicateVoteEvidence {
}
func TestDuplicateVoteEvidence(t *testing.T) {
const height = int64(13)
const height = uint64(13)
ev := NewMockDuplicateVoteEvidence(height, time.Now(), "mock-chain-id")
assert.Equal(t, ev.Hash(), tmhash.Sum(ev.Bytes()))
assert.NotNil(t, ev.String())
@@ -89,7 +89,7 @@ func TestDuplicateVoteEvidenceValidation(t *testing.T) {
}
func TestLightClientAttackEvidence(t *testing.T) {
height := int64(5)
height := uint64(5)
voteSet, valSet, privVals := randVoteSet(height, 1, tmproto.PrecommitType, 10, 1)
header := makeHeaderRandom()
header.Height = height
@@ -152,7 +152,7 @@ func TestLightClientAttackEvidence(t *testing.T) {
}
func TestLightClientAttackEvidenceValidation(t *testing.T) {
height := int64(5)
height := uint64(5)
voteSet, valSet, privVals := randVoteSet(height, 1, tmproto.PrecommitType, 10, 1)
header := makeHeaderRandom()
header.Height = height
@@ -178,7 +178,6 @@ func TestLightClientAttackEvidenceValidation(t *testing.T) {
expectErr bool
}{
{"Good DuplicateVoteEvidence", func(ev *LightClientAttackEvidence) {}, false},
{"Negative height", func(ev *LightClientAttackEvidence) { ev.CommonHeight = -10 }, true},
{"Height is greater than divergent block", func(ev *LightClientAttackEvidence) {
ev.CommonHeight = height + 1
}, true},
@@ -213,12 +212,12 @@ func TestLightClientAttackEvidenceValidation(t *testing.T) {
}
func TestMockEvidenceValidateBasic(t *testing.T) {
goodEvidence := NewMockDuplicateVoteEvidence(int64(1), time.Now(), "mock-chain-id")
goodEvidence := NewMockDuplicateVoteEvidence(uint64(1), time.Now(), "mock-chain-id")
assert.Nil(t, goodEvidence.ValidateBasic())
}
func makeVote(
t *testing.T, val PrivValidator, chainID string, valIndex int32, height int64, round int32, step int, blockID BlockID,
t *testing.T, val PrivValidator, chainID string, valIndex int32, height uint64, round int32, step int, blockID BlockID,
time time.Time) *Vote {
pubKey, err := val.GetPubKey()
require.NoError(t, err)
@@ -245,7 +244,7 @@ func makeHeaderRandom() *Header {
return &Header{
Version: version.Consensus{Block: version.BlockProtocol, App: 1},
ChainID: tmrand.Str(12),
Height: int64(tmrand.Uint16()) + 1,
Height: uint64(tmrand.Uint16()) + 1,
Time: time.Now(),
LastBlockID: makeBlockIDRandom(),
LastCommitHash: crypto.CRandBytes(tmhash.Size),
@@ -270,7 +269,7 @@ func TestEvidenceProto(t *testing.T) {
v2 := makeVote(t, val, chainID, math.MaxInt32, math.MaxInt64, 2, 0x01, blockID2, defaultVoteTime)
// -------- SignedHeaders --------
const height int64 = 37
const height uint64 = 37
var (
header1 = makeHeaderRandom()
+1 -1
View File
@@ -37,7 +37,7 @@ type GenesisValidator struct {
type GenesisDoc struct {
GenesisTime time.Time `json:"genesis_time"`
ChainID string `json:"chain_id"`
InitialHeight int64 `json:"initial_height"`
InitialHeight uint64 `json:"initial_height"`
ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"`
Validators []GenesisValidator `json:"validators,omitempty"`
AppHash tmbytes.HexBytes `json:"app_hash"`
+2 -2
View File
@@ -24,7 +24,7 @@ var (
// If POLRound >= 0, then BlockID corresponds to the block that is locked in POLRound.
type Proposal struct {
Type tmproto.SignedMsgType
Height int64 `json:"height"`
Height uint64 `json:"height"`
Round int32 `json:"round"` // there can not be greater than 2_147_483_647 rounds
POLRound int32 `json:"pol_round"` // -1 if null.
BlockID BlockID `json:"block_id"`
@@ -34,7 +34,7 @@ type Proposal struct {
// NewProposal returns a new Proposal.
// If there is no POLRound, polRound should be -1.
func NewProposal(height int64, round int32, polRound int32, blockID BlockID) *Proposal {
func NewProposal(height uint64, round int32, polRound int32, blockID BlockID) *Proposal {
return &Proposal{
Type: tmproto.ProposalType,
Height: height,
-1
View File
@@ -132,7 +132,6 @@ func TestProposalValidateBasic(t *testing.T) {
}{
{"Good Proposal", func(p *Proposal) {}, false},
{"Invalid Type", func(p *Proposal) { p.Type = tmproto.PrecommitType }, true},
{"Invalid Height", func(p *Proposal) { p.Height = -1 }, true},
{"Invalid Round", func(p *Proposal) { p.Round = -1 }, true},
{"Invalid POLRound", func(p *Proposal) { p.POLRound = -2 }, true},
{"Invalid BlockId", func(p *Proposal) {
+2 -2
View File
@@ -7,7 +7,7 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
func MakeCommit(blockID BlockID, height int64, round int32,
func MakeCommit(blockID BlockID, height uint64, round int32,
voteSet *VoteSet, validators []PrivValidator, now time.Time) (*Commit, error) {
// all sign
@@ -46,7 +46,7 @@ func signAddVote(privVal PrivValidator, vote *Vote, voteSet *VoteSet) (signed bo
}
func MakeVote(
height int64,
height uint64,
blockID BlockID,
valSet *ValidatorSet,
privVal PrivValidator,
+2 -2
View File
@@ -660,7 +660,7 @@ func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error {
// includes which validators signed. For instance, Gaia incentivizes proposers
// with a bonus for including more than +2/3 of the signatures.
func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID,
height int64, commit *Commit) error {
height uint64, commit *Commit) error {
if commit == nil {
return errors.New("nil commit")
}
@@ -718,7 +718,7 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID,
// This method is primarily used by the light client and does not check all the
// signatures.
func (vals *ValidatorSet) VerifyCommitLight(chainID string, blockID BlockID,
height int64, commit *Commit) error {
height uint64, commit *Commit) error {
if commit == nil {
return errors.New("nil commit")
}
+4 -4
View File
@@ -693,7 +693,7 @@ func TestValidatorSet_VerifyCommit_All(t *testing.T) {
description string
chainID string
blockID BlockID
height int64
height uint64
commit *Commit
expErr bool
}{
@@ -744,7 +744,7 @@ func TestValidatorSet_VerifyCommit_All(t *testing.T) {
func TestValidatorSet_VerifyCommit_CheckAllSignatures(t *testing.T) {
var (
chainID = "test_chain_id"
h = int64(3)
h = uint64(3)
blockID = makeBlockIDRandom()
)
@@ -769,7 +769,7 @@ func TestValidatorSet_VerifyCommit_CheckAllSignatures(t *testing.T) {
func TestValidatorSet_VerifyCommitLight_ReturnsAsSoonAsMajorityOfVotingPowerSigned(t *testing.T) {
var (
chainID = "test_chain_id"
h = int64(3)
h = uint64(3)
blockID = makeBlockIDRandom()
)
@@ -792,7 +792,7 @@ func TestValidatorSet_VerifyCommitLight_ReturnsAsSoonAsMajorityOfVotingPowerSign
func TestValidatorSet_VerifyCommitLightTrusting_ReturnsAsSoonAsTrustLevelOfVotingPowerSigned(t *testing.T) {
var (
chainID = "test_chain_id"
h = int64(3)
h = uint64(3)
blockID = makeBlockIDRandom()
)
+1 -5
View File
@@ -49,7 +49,7 @@ type Address = crypto.Address
// consensus.
type Vote struct {
Type tmproto.SignedMsgType `json:"type"`
Height int64 `json:"height"`
Height uint64 `json:"height"`
Round int32 `json:"round"` // assume there will not be greater than 2_147_483_647 rounds
BlockID BlockID `json:"block_id"` // zero if vote is nil.
Timestamp time.Time `json:"timestamp"`
@@ -161,10 +161,6 @@ func (vote *Vote) ValidateBasic() error {
return errors.New("invalid Type")
}
if vote.Height < 0 {
return errors.New("negative Height")
}
if vote.Round < 0 {
return errors.New("negative Round")
}
+3 -3
View File
@@ -60,7 +60,7 @@ type P2PID string
*/
type VoteSet struct {
chainID string
height int64
height uint64
round int32
signedMsgType tmproto.SignedMsgType
valSet *ValidatorSet
@@ -75,7 +75,7 @@ type VoteSet struct {
}
// Constructs a new VoteSet struct used to accumulate votes for given height/round.
func NewVoteSet(chainID string, height int64, round int32,
func NewVoteSet(chainID string, height uint64, round int32,
signedMsgType tmproto.SignedMsgType, valSet *ValidatorSet) *VoteSet {
if height == 0 {
panic("Cannot make VoteSet for height == 0, doesn't make sense.")
@@ -100,7 +100,7 @@ func (voteSet *VoteSet) ChainID() string {
}
// Implements VoteSetReader.
func (voteSet *VoteSet) GetHeight() int64 {
func (voteSet *VoteSet) GetHeight() uint64 {
if voteSet == nil {
return 0
}
+8 -8
View File
@@ -14,7 +14,7 @@ import (
)
func TestVoteSet_AddVote_Good(t *testing.T) {
height, round := int64(1), int32(0)
height, round := uint64(1), int32(0)
voteSet, _, privValidators := randVoteSet(height, round, tmproto.PrevoteType, 10, 1)
val0 := privValidators[0]
@@ -46,7 +46,7 @@ func TestVoteSet_AddVote_Good(t *testing.T) {
}
func TestVoteSet_AddVote_Bad(t *testing.T) {
height, round := int64(1), int32(0)
height, round := uint64(1), int32(0)
voteSet, _, privValidators := randVoteSet(height, round, tmproto.PrevoteType, 10, 1)
voteProto := &Vote{
@@ -121,7 +121,7 @@ func TestVoteSet_AddVote_Bad(t *testing.T) {
}
func TestVoteSet_2_3Majority(t *testing.T) {
height, round := int64(1), int32(0)
height, round := uint64(1), int32(0)
voteSet, _, privValidators := randVoteSet(height, round, tmproto.PrevoteType, 10, 1)
voteProto := &Vote{
@@ -171,7 +171,7 @@ func TestVoteSet_2_3Majority(t *testing.T) {
}
func TestVoteSet_2_3MajorityRedux(t *testing.T) {
height, round := int64(1), int32(0)
height, round := uint64(1), int32(0)
voteSet, _, privValidators := randVoteSet(height, round, tmproto.PrevoteType, 100, 1)
blockHash := crypto.CRandBytes(32)
@@ -270,7 +270,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
}
func TestVoteSet_Conflicts(t *testing.T) {
height, round := int64(1), int32(0)
height, round := uint64(1), int32(0)
voteSet, _, privValidators := randVoteSet(height, round, tmproto.PrevoteType, 4, 1)
blockHash1 := tmrand.Bytes(32)
blockHash2 := tmrand.Bytes(32)
@@ -399,7 +399,7 @@ func TestVoteSet_Conflicts(t *testing.T) {
}
func TestVoteSet_MakeCommit(t *testing.T) {
height, round := int64(1), int32(0)
height, round := uint64(1), int32(0)
voteSet, _, privValidators := randVoteSet(height, round, tmproto.PrecommitType, 10, 1)
blockHash, blockPartSetHeader := crypto.CRandBytes(32), PartSetHeader{123, crypto.CRandBytes(32)}
@@ -476,7 +476,7 @@ func TestVoteSet_MakeCommit(t *testing.T) {
// NOTE: privValidators are in order
func randVoteSet(
height int64,
height uint64,
round int32,
signedMsgType tmproto.SignedMsgType,
numValidators int,
@@ -495,7 +495,7 @@ func withValidator(vote *Vote, addr []byte, idx int32) *Vote {
}
// Convenience: Return new vote with different height
func withHeight(vote *Vote, height int64) *Vote {
func withHeight(vote *Vote, height uint64) *Vote {
vote = vote.Copy()
vote.Height = height
return vote
-1
View File
@@ -240,7 +240,6 @@ func TestVoteValidateBasic(t *testing.T) {
expectErr bool
}{
{"Good Vote", func(v *Vote) {}, false},
{"Negative Height", func(v *Vote) { v.Height = -1 }, true},
{"Negative Round", func(v *Vote) { v.Round = -1 }, true},
{"Invalid BlockID", func(v *Vote) {
v.BlockID = BlockID{[]byte{1, 2, 3}, PartSetHeader{111, []byte("blockparts")}}