Skip to content

Commit

Permalink
Fixed block_test and validation_test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalicevic committed Jan 11, 2025
1 parent b9c5a03 commit 2670544
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
18 changes: 13 additions & 5 deletions types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ func TestCommit(t *testing.T) {
require.NotNil(t, extCommit.BitArray())
assert.Equal(t, bits.NewBitArray(10).Size(), extCommit.BitArray().Size())

assert.Equal(t, voteSet.GetByIndex(0), extCommit.GetByIndex(0))
vote1, err := voteSet.GetByIndex(0)
require.NoError(t, err)
vote2, err := extCommit.GetByIndex(0)
require.NoError(t, err)
assert.Equal(t, vote1, vote2)
assert.True(t, extCommit.IsCommit())
}

Expand Down Expand Up @@ -564,7 +568,8 @@ func TestVoteSetToExtendedCommit(t *testing.T) {
ec := voteSet.MakeExtendedCommit(p)

for i := int32(0); int(i) < len(vals); i++ {
vote1 := voteSet.GetByIndex(i)
vote1, err := voteSet.GetByIndex(i)
require.NoError(t, err)
vote2 := ec.GetExtendedVote(i)

vote1bz, err := vote1.ToProto().Marshal()
Expand Down Expand Up @@ -614,7 +619,8 @@ func TestExtendedCommitToVoteSet(t *testing.T) {

if !testCase.includeExtension {
for i := 0; i < len(vals); i++ {
v := voteSet.GetByIndex(int32(i))
v, err := voteSet.GetByIndex(int32(i))
require.NoError(t, err)
v.Extension = nil
v.ExtensionSignature = nil
extCommit.ExtendedSignatures[i].Extension = nil
Expand All @@ -631,8 +637,10 @@ func TestExtendedCommitToVoteSet(t *testing.T) {
}

for i := int32(0); int(i) < len(vals); i++ {
vote1 := voteSet.GetByIndex(i)
vote2 := voteSet2.GetByIndex(i)
vote1, err := voteSet.GetByIndex(i)
require.NoError(t, err)
vote2, err := voteSet2.GetByIndex(i)
require.NoError(t, err)
vote3 := extCommit.GetExtendedVote(i)

vote1bz, err := vote1.ToProto().Marshal()
Expand Down
9 changes: 6 additions & 3 deletions types/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ func TestValidatorSet_VerifyCommit_CheckAllSignatures(t *testing.T) {
require.NoError(t, valSet.VerifyCommit(chainID, blockID, h, commit))

// malleate 4th signature
vote := voteSet.GetByIndex(3)
vote, err := voteSet.GetByIndex(3)
require.NoError(t, err)
v := vote.ToProto()
err = vals[3].SignVote("CentaurusA", v, true)
require.NoError(t, err)
Expand Down Expand Up @@ -197,7 +198,8 @@ func TestValidatorSet_VerifyCommitLight_ReturnsAsSoonAsMajOfVotingPowerSignedIff
require.NoError(t, err)

// malleate 4th signature (3 signatures are enough for 2/3+)
vote := voteSet.GetByIndex(3)
vote, err := voteSet.GetByIndex(3)
require.NoError(t, err)
v := vote.ToProto()
err = vals[3].SignVote("CentaurusA", v, true)
require.NoError(t, err)
Expand Down Expand Up @@ -232,7 +234,8 @@ func TestValidatorSet_VerifyCommitLightTrusting_ReturnsAsSoonAsTrustLevelSignedI
require.NoError(t, err)

// malleate 3rd signature (2 signatures are enough for 1/3+ trust level)
vote := voteSet.GetByIndex(2)
vote, err := voteSet.GetByIndex(2)
require.NoError(t, err)
v := vote.ToProto()
err = vals[2].SignVote("CentaurusA", v, true)
require.NoError(t, err)
Expand Down

0 comments on commit 2670544

Please sign in to comment.