Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
durkmurder committed May 12, 2023
1 parent 1063a51 commit bbc49b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions consensus/hotstuff/model/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ func (e InvalidProposalError) Error() string {
)
}

func (e InvalidProposalError) Unwrap() error {
return e.Err
}

// IsInvalidProposalError returns whether an error is InvalidProposalError
func IsInvalidProposalError(err error) bool {
var e InvalidProposalError
Expand Down
4 changes: 2 additions & 2 deletions engine/collection/compliance/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsHotStuffValidation() {
cs.validator.On("ValidateProposal", hotstuffProposal).Return(sentinelError)
cs.proposalViolationNotifier.On("OnInvalidBlockDetected", sentinelError).Return().Once()
// we should notify VoteAggregator about the invalid block
cs.voteAggregator.On("InvalidProposal", hotstuffProposal).Return(nil)
cs.voteAggregator.On("InvalidBlock", hotstuffProposal).Return(nil)

// the expected error should be handled within the Core
err := cs.core.OnBlockProposal(originID, proposal)
Expand Down Expand Up @@ -361,7 +361,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsProtocolStateValidation() {
cs.state.On("Final").Return(func() clusterint.Snapshot { return cs.snapshot })
cs.state.On("Extend", mock.Anything).Return(state.NewInvalidExtensionError(""))
// we should notify VoteAggregator about the invalid block
cs.voteAggregator.On("InvalidProposal", hotstuffProposal).Return(nil)
cs.voteAggregator.On("InvalidBlock", hotstuffProposal).Return(nil)

// the expected error should be handled within the Core
err := cs.core.OnBlockProposal(originID, proposal)
Expand Down
4 changes: 2 additions & 2 deletions engine/consensus/compliance/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsHotStuffValidation() {
cs.validator.On("ValidateProposal", hotstuffProposal).Return(sentinelError)
cs.proposalViolationNotifier.On("OnInvalidBlockDetected", sentinelError).Return().Once()
// we should notify VoteAggregator about the invalid block
cs.voteAggregator.On("InvalidProposal", hotstuffProposal).Return(nil)
cs.voteAggregator.On("InvalidBlock", hotstuffProposal).Return(nil)

// the expected error should be handled within the Core
err := cs.core.OnBlockProposal(originID, proposal)
Expand Down Expand Up @@ -443,7 +443,7 @@ func (cs *CoreSuite) TestOnBlockProposal_FailsProtocolStateValidation() {
cs.state.On("Final").Return(func() protint.Snapshot { return cs.snapshot })
cs.state.On("Extend", mock.Anything, mock.Anything).Return(state.NewInvalidExtensionError(""))
// we should notify VoteAggregator about the invalid block
cs.voteAggregator.On("InvalidProposal", hotstuffProposal).Return(nil)
cs.voteAggregator.On("InvalidBlock", hotstuffProposal).Return(nil)

// the expected error should be handled within the Core
err := cs.core.OnBlockProposal(originID, proposal)
Expand Down

0 comments on commit bbc49b8

Please sign in to comment.