Skip to content

Commit ac73708

Browse files
durkmurderjordanschalm
authored andcommitted
Fixed unit test. Updated godoc
1 parent ba0c30b commit ac73708

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

consensus/hotstuff/committee.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ type BlockSignerDecoder interface {
130130
// consensus committee has reached agreement on validity of parent block. Consequently, the
131131
// returned IdentifierList contains the consensus participants that signed the parent block.
132132
// Expected Error returns during normal operations:
133-
// - model.ErrViewForUnknownEpoch if the given block's parent is within an unknown epoch
134133
// - signature.InvalidSignerIndicesError if signer indices included in the header do
135134
// not encode a valid subset of the consensus committee
136135
DecodeSignerIDs(header *flow.Header) (flow.IdentifierList, error)

consensus/hotstuff/signature/block_signer_decoder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ var _ hotstuff.BlockSignerDecoder = (*BlockSignerDecoder)(nil)
2727
// consensus committee has reached agreement on validity of parent block. Consequently, the
2828
// returned IdentifierList contains the consensus participants that signed the parent block.
2929
// Expected Error returns during normal operations:
30-
// - model.ErrViewForUnknownEpoch if the given block's parent is within an unknown epoch
3130
// - signature.InvalidSignerIndicesError if signer indices included in the header do
3231
// not encode a valid subset of the consensus committee
3332
func (b *BlockSignerDecoder) DecodeSignerIDs(header *flow.Header) (flow.IdentifierList, error) {
@@ -44,7 +43,8 @@ func (b *BlockSignerDecoder) DecodeSignerIDs(header *flow.Header) (flow.Identifi
4443
// try asking by parent ID
4544
members, err = b.IdentitiesByBlock(header.ParentID)
4645
if err != nil {
47-
return nil, fmt.Errorf("could not retrieve identities for block %x with QC view %d for parent %x: %w", header.ID(), header.ParentView, header.ParentID, err)
46+
return nil, fmt.Errorf("could not retrieve identities for block %x with QC view %d for parent %x: %w",
47+
header.ID(), header.ParentView, header.ParentID, err)
4848
}
4949
} else {
5050
return nil, fmt.Errorf("unexpected error retrieving identities for block %v: %w", header.ID(), err)

consensus/hotstuff/signature/block_signer_decoder_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package signature
22

33
import (
44
"errors"
5+
"fmt"
56
"testing"
67

78
"github.com/stretchr/testify/mock"
@@ -84,11 +85,12 @@ func (s *blockSignerDecoderSuite) Test_UnexpectedCommitteeException() {
8485
// It should propagate the sentinel error model.ErrViewForUnknownEpoch from Committee.
8586
func (s *blockSignerDecoderSuite) Test_UnknownEpoch() {
8687
*s.committee = *hotstuff.NewDynamicCommittee(s.T())
87-
s.committee.On("IdentitiesByEpoch", mock.Anything).Return(nil, model.ErrViewForUnknownEpoch)
88+
s.committee.On("IdentitiesByEpoch", s.block.Header.ParentView).Return(nil, model.ErrViewForUnknownEpoch)
89+
s.committee.On("IdentitiesByBlock", s.block.Header.ParentID).Return(nil, fmt.Errorf(""))
8890

8991
ids, err := s.decoder.DecodeSignerIDs(s.block.Header)
9092
require.Empty(s.T(), ids)
91-
require.ErrorIs(s.T(), err, model.ErrViewForUnknownEpoch)
93+
require.Error(s.T(), err)
9294
}
9395

9496
// Test_InvalidIndices verifies that `BlockSignerDecoder` returns

0 commit comments

Comments
 (0)