Skip to content

Commit

Permalink
Fix Test_createAggregatedBLSPubKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Oct 15, 2023
1 parent 5718965 commit cf7c654
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 4 additions & 0 deletions consensus/ibft/signer/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ func extractSignerPubKeys(
vals validators.Validators,
bitMap *big.Int,
) ([]*bls.PublicKey, int, error) {
if bitMap.BitLen() == 0 {
return nil, 0, ErrExpectedAtLeastOneSigner
}

pubKeys := make([]*bls.PublicKey, 0, vals.Len())

for idx := 0; idx < vals.Len(); idx++ {
Expand Down
9 changes: 4 additions & 5 deletions consensus/ibft/signer/bls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,6 @@ func Test_getBLSSignatures(t *testing.T) {
}

func Test_createAggregatedBLSPubKeys(t *testing.T) {
t.Skip("FIXME")
t.Parallel()

t.Run("multiple validators", func(t *testing.T) {
Expand Down Expand Up @@ -838,14 +837,14 @@ func Test_createAggregatedBLSPubKeys(t *testing.T) {
t.Run("should return error if bitMap is empty", func(t *testing.T) {
t.Parallel()

aggrecatedPubKeys, num, err := extractSignerPubKeys(
aggregatedPubKeys, num, err := extractSignerPubKeys(
validators.NewBLSValidatorSet(),
new(big.Int),
)

assert.Nil(t, aggrecatedPubKeys)
assert.Nil(t, aggregatedPubKeys)
assert.Zero(t, num)
assert.ErrorContains(t, err, "at least one public key is required")
assert.ErrorIs(t, err, ErrExpectedAtLeastOneSigner)
})

t.Run("should return error if public key is wrong", func(t *testing.T) {
Expand All @@ -863,7 +862,7 @@ func Test_createAggregatedBLSPubKeys(t *testing.T) {

assert.Nil(t, aggPubKeys)
assert.Zero(t, num)
assert.ErrorContains(t, err, "public key must be 48 bytes")
assert.ErrorIs(t, err, bls.ErrInvalidPublicKeySize)
})
}

Expand Down
1 change: 1 addition & 0 deletions consensus/ibft/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
ErrInvalidValidators = errors.New("invalid validators type")
ErrInvalidValidator = errors.New("invalid validator type")
ErrInvalidSignature = errors.New("invalid signature")
ErrExpectedAtLeastOneSigner = errors.New("expected at least one signer")
)

// Signer is responsible for signing for blocks and messages in IBFT
Expand Down
5 changes: 0 additions & 5 deletions validators/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ package validators

import (
"bytes"
"errors"
"fmt"

"github.com/0xPolygon/polygon-edge/helper/hex"
"github.com/0xPolygon/polygon-edge/types"
"github.com/umbracle/fastrlp"
)

var (
ErrInvalidTypeAssert = errors.New("invalid type assert")
)

type BLSValidatorPublicKey []byte

// String returns a public key in hex
Expand Down

0 comments on commit cf7c654

Please sign in to comment.