From bbc49b82de4c646655eb681370ede430c14296ec Mon Sep 17 00:00:00 2001 From: Yurii Oleksyshyn Date: Fri, 12 May 2023 14:32:17 +0300 Subject: [PATCH] Fixed tests --- consensus/hotstuff/model/errors.go | 4 ++++ engine/collection/compliance/core_test.go | 4 ++-- engine/consensus/compliance/core_test.go | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/consensus/hotstuff/model/errors.go b/consensus/hotstuff/model/errors.go index 3ee63351b06..4244d0ac531 100644 --- a/consensus/hotstuff/model/errors.go +++ b/consensus/hotstuff/model/errors.go @@ -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 diff --git a/engine/collection/compliance/core_test.go b/engine/collection/compliance/core_test.go index b8db7dfe0f2..81f19c2f3b1 100644 --- a/engine/collection/compliance/core_test.go +++ b/engine/collection/compliance/core_test.go @@ -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) @@ -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) diff --git a/engine/consensus/compliance/core_test.go b/engine/consensus/compliance/core_test.go index b48ae4375a5..270a417411b 100644 --- a/engine/consensus/compliance/core_test.go +++ b/engine/consensus/compliance/core_test.go @@ -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) @@ -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)