Skip to content

Commit

Permalink
Fix TestBLSKeyManagerGenerateCommittedSeals
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Oct 15, 2023
1 parent 9156c95 commit 0e3097f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions consensus/ibft/signer/bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ func getBLSSignatures(
sealMap map[types.Address][]byte,
validators validators.Validators,
) ([]*bls.Signature, *big.Int, error) {
if len(sealMap) == 0 {
return nil, nil, ErrEmptyCommittedSeals
}

blsSignatures := make([]*bls.Signature, 0, len(sealMap))
bitMap := new(big.Int)

Expand Down
17 changes: 8 additions & 9 deletions consensus/ibft/signer/bls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,24 +414,23 @@ func TestBLSKeyManagerVerifyCommittedSeal(t *testing.T) {
}

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

blsKeyManager1, _, _ := newTestBLSKeyManager(t)
blsKeyManager, _, _ := newTestBLSKeyManager(t)

msg := crypto.Keccak256(
wrapCommitHash(
hex.MustDecodeHex(testHeaderHashHex),
),
)

correctCommittedSeal, err := blsKeyManager1.SignCommittedSeal(msg)
correctCommittedSeal, err := blsKeyManager.SignCommittedSeal(msg)
assert.NoError(t, err)

aggregatedBLSSigBytes := testCreateAggregatedSignature(
t,
msg,
blsKeyManager1,
blsKeyManager,
)

tests := []struct {
Expand All @@ -451,7 +450,7 @@ func TestBLSKeyManagerGenerateCommittedSeals(t *testing.T) {
{
name: "should return error if getBLSSignatures returns error",
sealMap: map[types.Address][]byte{
blsKeyManager1.Address(): correctCommittedSeal,
blsKeyManager.Address(): correctCommittedSeal,
},
validators: validators.NewBLSValidatorSet(),
expectedRes: nil,
Expand All @@ -462,17 +461,17 @@ func TestBLSKeyManagerGenerateCommittedSeals(t *testing.T) {
sealMap: map[types.Address][]byte{},
validators: validators.NewBLSValidatorSet(),
expectedRes: nil,
expectedErr: errors.New("at least one signature is required"),
expectedErr: ErrEmptyCommittedSeals,
},
{
name: "should return AggregatedSeal if it's successful",
sealMap: map[types.Address][]byte{
blsKeyManager1.Address(): correctCommittedSeal,
blsKeyManager.Address(): correctCommittedSeal,
},
validators: validators.NewBLSValidatorSet(
testBLSKeyManagerToBLSValidator(
t,
blsKeyManager1,
blsKeyManager,
),
),
expectedRes: &AggregatedSeal{
Expand All @@ -489,7 +488,7 @@ func TestBLSKeyManagerGenerateCommittedSeals(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
t.Parallel()

res, err := blsKeyManager1.GenerateCommittedSeals(
res, err := blsKeyManager.GenerateCommittedSeals(
test.sealMap,
test.validators,
)
Expand Down

0 comments on commit 0e3097f

Please sign in to comment.