Skip to content

Commit

Permalink
Fixed panicing tests because of incorrect PubKey type
Browse files Browse the repository at this point in the history
  • Loading branch information
alesforz committed Jan 10, 2025
1 parent 3c4c3a8 commit c71b2cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/bls12381/aggregation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func TestAggregateAndVerify(t *testing.T) {

pubKeys := make([]*bls12381.PubKey, len(privateKeys))
for i, privKey := range privateKeys {
pubKeys[i] = privKey.PubKey().(*bls12381.PubKey)
pubKey := privKey.PubKey().(bls12381.PubKey)
pubKeys[i] = &pubKey
}

// Verify aggregated signature
Expand Down
9 changes: 9 additions & 0 deletions types/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ import (
"github.com/stretchr/testify/require"

"github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/crypto/bls12381"
)

func TestValidatorProtoBuf(t *testing.T) {
val, _ := RandValidator(true, 100)

// FIXME: we have to do this manual conversion because val's PubKey is set to
// type bls12381.PubKey, but we expect it to be of type *bls12381.PubKey.
// The long-term solution is to revisit the method bls12381.PubKey() to make it
// return a *bls12381.PubKey.
valPubKey := val.PubKey.(bls12381.PubKey)
val.PubKey = &valPubKey

testCases := []struct {
msg string
v1 *Validator
Expand Down

0 comments on commit c71b2cc

Please sign in to comment.