use of com.radixdlt.hotstuff.Vote in project radixdlt by radixdlt.
the class BFTEventReducerTest method when_process_vote_with_quorum_wrong_view__then_ignored.
@Test
public void when_process_vote_with_quorum_wrong_view__then_ignored() {
Vote vote = mock(Vote.class);
when(vote.getView()).thenReturn(View.of(1));
this.bftEventReducer.processViewUpdate(ViewUpdate.create(View.of(3), mock(HighQC.class), mock(BFTNode.class), this.self));
this.bftEventReducer.processVote(vote);
verifyNoMoreInteractions(this.pendingVotes);
}
use of com.radixdlt.hotstuff.Vote in project radixdlt by radixdlt.
the class BFTEventReducerTest method when_process_vote_with_quorum__then_processed.
@Test
public void when_process_vote_with_quorum__then_processed() {
BFTNode author = mock(BFTNode.class);
Vote vote = mock(Vote.class);
when(vote.getAuthor()).thenReturn(author);
QuorumCertificate qc = mock(QuorumCertificate.class);
HighQC highQc = mock(HighQC.class);
QuorumCertificate highestCommittedQc = mock(QuorumCertificate.class);
when(highQc.highestCommittedQC()).thenReturn(highestCommittedQc);
when(vote.getView()).thenReturn(View.of(1));
when(this.pendingVotes.insertVote(any(), any())).thenReturn(VoteProcessingResult.qcQuorum(qc));
when(this.vertexStore.highQC()).thenReturn(highQc);
// Move to view 1
this.bftEventReducer.processViewUpdate(ViewUpdate.create(View.of(1), highQc, mock(BFTNode.class), this.self));
this.bftEventReducer.processVote(vote);
verify(this.viewQuorumReachedEventDispatcher, times(1)).dispatch(any());
verify(this.pendingVotes, times(1)).insertVote(eq(vote), any());
verifyNoMoreInteractions(this.pendingVotes);
}
use of com.radixdlt.hotstuff.Vote in project radixdlt by radixdlt.
the class BFTEventVerifierTest method when_process_correct_vote_then_should_be_forwarded.
@Test
public void when_process_correct_vote_then_should_be_forwarded() {
Vote vote = mock(Vote.class);
when(vote.getView()).thenReturn(View.of(1));
when(vote.getEpoch()).thenReturn(0L);
BFTNode author = mock(BFTNode.class);
when(vote.getAuthor()).thenReturn(author);
ECDSASignature voteSignature = mock(ECDSASignature.class);
ECDSASignature timeoutSignature = mock(ECDSASignature.class);
when(vote.getSignature()).thenReturn(voteSignature);
when(vote.getTimeoutSignature()).thenReturn(Optional.of(timeoutSignature));
when(validatorSet.containsNode(eq(author))).thenReturn(true);
when(verifier.verify(any(), any(), eq(voteSignature))).thenReturn(true);
when(verifier.verify(any(), any(), eq(timeoutSignature))).thenReturn(true);
when(safetyRules.verifyHighQcAgainstTheValidatorSet(any())).thenReturn(true);
eventVerifier.processVote(vote);
verify(forwardTo, times(1)).processVote(eq(vote));
}
use of com.radixdlt.hotstuff.Vote in project radixdlt by radixdlt.
the class BFTEventVerifierTest method when_process_bad_timeout_signature_vote_then_should_not_be_forwarded.
@Test
public void when_process_bad_timeout_signature_vote_then_should_not_be_forwarded() {
Vote vote = mock(Vote.class);
when(vote.getView()).thenReturn(View.of(1));
when(vote.getEpoch()).thenReturn(0L);
BFTNode author = mock(BFTNode.class);
when(vote.getAuthor()).thenReturn(author);
ECDSASignature voteSignature = mock(ECDSASignature.class);
ECDSASignature timeoutSignature = mock(ECDSASignature.class);
when(vote.getSignature()).thenReturn(voteSignature);
when(vote.getTimeoutSignature()).thenReturn(Optional.of(timeoutSignature));
when(validatorSet.containsNode(eq(author))).thenReturn(true);
when(verifier.verify(any(), any(), eq(voteSignature))).thenReturn(true);
when(verifier.verify(any(), any(), eq(timeoutSignature))).thenReturn(false);
eventVerifier.processVote(vote);
verify(forwardTo, never()).processVote(any());
}
use of com.radixdlt.hotstuff.Vote in project radixdlt by radixdlt.
the class BFTEventVerifierTest method when_process_bad_signature_vote_then_should_not_be_forwarded.
@Test
public void when_process_bad_signature_vote_then_should_not_be_forwarded() {
Vote vote = mock(Vote.class);
BFTNode author = mock(BFTNode.class);
when(vote.getAuthor()).thenReturn(author);
when(vote.getSignature()).thenReturn(mock(ECDSASignature.class));
when(validatorSet.containsNode(eq(author))).thenReturn(true);
when(verifier.verify(any(), any(), any())).thenReturn(false);
eventVerifier.processVote(vote);
verify(forwardTo, never()).processVote(any());
}
Aggregations