use of com.radixdlt.crypto.ECDSASignature 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.crypto.ECDSASignature 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);
eventVerifier.processVote(vote);
verify(forwardTo, times(1)).processVote(eq(vote));
}
use of com.radixdlt.crypto.ECDSASignature in project radixdlt by radixdlt.
the class SafetyRules method signProposal.
/**
* Create a signed proposal from a vertex
*
* @param proposedVertex vertex to sign
* @param highestCommittedQC highest known committed QC
* @param highestTC highest known TC
* @return signed proposal object for consensus
*/
public Optional<Proposal> signProposal(VerifiedVertex proposedVertex, QuorumCertificate highestCommittedQC, Optional<TimeoutCertificate> highestTC) {
final Builder safetyStateBuilder = this.state.toBuilder();
if (!checkLocked(proposedVertex, safetyStateBuilder)) {
return Optional.empty();
}
this.state = safetyStateBuilder.build();
final ECDSASignature signature = this.signer.sign(proposedVertex.getId());
return Optional.of(new Proposal(proposedVertex.toSerializable(), highestCommittedQC, signature, highestTC));
}
use of com.radixdlt.crypto.ECDSASignature 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.crypto.ECDSASignature 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());
}
Aggregations