Skip to content

Commit

Permalink
getting compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
blasrodri committed Mar 22, 2024
1 parent 3a1b088 commit ed525e5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions types/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestProposalVerifySignature(t *testing.T) {

prop := NewProposal(
4, 2, 2,
BlockID{cmtrand.Bytes(tmhash.Size), PartSetHeader{777, cmtrand.Bytes(tmhash.Size)}})
BlockID{cmtrand.Bytes(tmhash.Size), PartSetHeader{777, cmtrand.Bytes(tmhash.Size)}, cmtrand.Bytes(tmhash.Size)})
p := prop.ToProto()
signBytes := ProposalSignBytes("test_chain_id", p)

Expand Down Expand Up @@ -136,7 +136,7 @@ func TestProposalValidateBasic(t *testing.T) {
{"Invalid Round", func(p *Proposal) { p.Round = -1 }, true},
{"Invalid POLRound", func(p *Proposal) { p.POLRound = -2 }, true},
{"Invalid BlockId", func(p *Proposal) {
p.BlockID = BlockID{[]byte{1, 2, 3}, PartSetHeader{111, []byte("blockparts")}}
p.BlockID = BlockID{[]byte{1, 2, 3}, PartSetHeader{111, []byte("blockparts")}, []byte{1, 2, 3}}
}, true},
{"Invalid Signature", func(p *Proposal) {
p.Signature = make([]byte, 0)
Expand Down
23 changes: 13 additions & 10 deletions types/vote_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestVoteSet_AddVote_Good(t *testing.T) {
Round: round,
Type: cmtproto.PrevoteType,
Timestamp: cmttime.Now(),
BlockID: BlockID{nil, PartSetHeader{}},
BlockID: BlockID{nil, PartSetHeader{}, nil},
}
_, err = signAddVote(val0, vote, voteSet)
require.NoError(t, err)
Expand All @@ -56,7 +56,7 @@ func TestVoteSet_AddVote_Bad(t *testing.T) {
Round: round,
Timestamp: cmttime.Now(),
Type: cmtproto.PrevoteType,
BlockID: BlockID{nil, PartSetHeader{}},
BlockID: BlockID{nil, PartSetHeader{}, nil},
}

// val0 votes for nil.
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestVoteSet_2_3Majority(t *testing.T) {
Round: round,
Type: cmtproto.PrevoteType,
Timestamp: cmttime.Now(),
BlockID: BlockID{nil, PartSetHeader{}},
BlockID: BlockID{nil, PartSetHeader{}, nil},
}
// 6 out of 10 voted for nil.
for i := int32(0); i < 6; i++ {
Expand Down Expand Up @@ -175,6 +175,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
voteSet, _, privValidators := randVoteSet(height, round, cmtproto.PrevoteType, 100, 1)

blockHash := crypto.CRandBytes(32)
blockHashAbiEncoded := crypto.CRandBytes(32)
blockPartsTotal := uint32(123)
blockPartSetHeader := PartSetHeader{blockPartsTotal, crypto.CRandBytes(32)}

Expand All @@ -185,7 +186,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
Round: round,
Timestamp: cmttime.Now(),
Type: cmtproto.PrevoteType,
BlockID: BlockID{blockHash, blockPartSetHeader},
BlockID: BlockID{blockHash, blockPartSetHeader, blockHashAbiEncoded},
}

// 66 out of 100 voted for nil.
Expand Down Expand Up @@ -264,7 +265,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) {
_, err = signAddVote(privValidators[70], vote, voteSet)
require.NoError(t, err)
blockID, ok = voteSet.TwoThirdsMajority()
assert.True(t, ok && blockID.Equals(BlockID{blockHash, blockPartSetHeader}),
assert.True(t, ok && blockID.Equals(BlockID{blockHash, blockPartSetHeader, blockHashAbiEncoded}),
"there should be 2/3 majority")
}
}
Expand All @@ -274,6 +275,7 @@ func TestVoteSet_Conflicts(t *testing.T) {
voteSet, _, privValidators := randVoteSet(height, round, cmtproto.PrevoteType, 4, 1)
blockHash1 := cmtrand.Bytes(32)
blockHash2 := cmtrand.Bytes(32)
blockHashAbiEncoded := cmtrand.Bytes(32)

voteProto := &Vote{
ValidatorAddress: nil,
Expand All @@ -282,7 +284,7 @@ func TestVoteSet_Conflicts(t *testing.T) {
Round: round,
Timestamp: cmttime.Now(),
Type: cmtproto.PrevoteType,
BlockID: BlockID{nil, PartSetHeader{}},
BlockID: BlockID{nil, PartSetHeader{}, nil},
}

val0, err := privValidators[0].GetPubKey()
Expand All @@ -307,7 +309,7 @@ func TestVoteSet_Conflicts(t *testing.T) {
}

// start tracking blockHash1
err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash1, PartSetHeader{}})
err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash1, PartSetHeader{}, blockHashAbiEncoded})
require.NoError(t, err)

// val0 votes again for blockHash1.
Expand All @@ -319,7 +321,7 @@ func TestVoteSet_Conflicts(t *testing.T) {
}

// attempt tracking blockHash2, should fail because already set for peerA.
err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash2, PartSetHeader{}})
err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash2, PartSetHeader{}, blockHashAbiEncoded})
require.Error(t, err)

// val0 votes again for blockHash1.
Expand Down Expand Up @@ -371,7 +373,7 @@ func TestVoteSet_Conflicts(t *testing.T) {
}

// now attempt tracking blockHash1
err = voteSet.SetPeerMaj23("peerB", BlockID{blockHash1, PartSetHeader{}})
err = voteSet.SetPeerMaj23("peerB", BlockID{blockHash1, PartSetHeader{}, blockHashAbiEncoded})
require.NoError(t, err)

// val2 votes for blockHash1.
Expand Down Expand Up @@ -402,6 +404,7 @@ func TestVoteSet_MakeCommit(t *testing.T) {
height, round := int64(1), int32(0)
voteSet, _, privValidators := randVoteSet(height, round, cmtproto.PrecommitType, 10, 1)
blockHash, blockPartSetHeader := crypto.CRandBytes(32), PartSetHeader{123, crypto.CRandBytes(32)}
blockHashAbiEncoded := crypto.CRandBytes(32)

voteProto := &Vote{
ValidatorAddress: nil,
Expand All @@ -410,7 +413,7 @@ func TestVoteSet_MakeCommit(t *testing.T) {
Round: round,
Timestamp: cmttime.Now(),
Type: cmtproto.PrecommitType,
BlockID: BlockID{blockHash, blockPartSetHeader},
BlockID: BlockID{blockHash, blockPartSetHeader, blockHashAbiEncoded},
}

// 6 out of 10 voted for some block.
Expand Down
2 changes: 1 addition & 1 deletion types/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestVoteValidateBasic(t *testing.T) {
{"Zero Height", func(v *Vote) { v.Height = 0 }, 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")}}
v.BlockID = BlockID{[]byte{1, 2, 3}, PartSetHeader{111, []byte("blockparts")}, []byte{1, 2, 3}}
}, true},
{"Invalid Address", func(v *Vote) { v.ValidatorAddress = make([]byte, 1) }, true},
{"Invalid ValidatorIndex", func(v *Vote) { v.ValidatorIndex = -1 }, true},
Expand Down

0 comments on commit ed525e5

Please sign in to comment.