Search in sources :

Example 21 with Vote

use of com.radixdlt.consensus.Vote in project radixdlt by radixdlt.

the class BFTEventVerifierTest method when_process_bad_author_vote_then_should_not_be_forwarded.

@Test
public void when_process_bad_author_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(false);
    when(verifier.verify(any(), any(), any())).thenReturn(true);
    eventVerifier.processVote(vote);
    verify(forwardTo, never()).processVote(any());
}
Also used : Vote(com.radixdlt.consensus.Vote) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Test(org.junit.Test)

Example 22 with Vote

use of com.radixdlt.consensus.Vote in project radixdlt by radixdlt.

the class SafetyStateTest method when_build_with_new_last_vote__then_should_build_with_new_last_vote.

@Test
public void when_build_with_new_last_vote__then_should_build_with_new_last_vote() {
    SafetyState safetyState = SafetyState.initialState();
    Builder builder = safetyState.toBuilder();
    Vote vote = mock(Vote.class);
    builder.lastVote(vote);
    SafetyState nextSafetyState = builder.build();
    assertThat(nextSafetyState.getLastVote()).isEqualTo(Optional.of(vote));
    assertThat(nextSafetyState.getLockedView()).isEqualTo(safetyState.getLockedView());
}
Also used : Vote(com.radixdlt.consensus.Vote) Builder(com.radixdlt.consensus.safety.SafetyState.Builder) Test(org.junit.Test)

Aggregations

Vote (com.radixdlt.consensus.Vote)22 Test (org.junit.Test)16 HighQC (com.radixdlt.consensus.HighQC)10 View (com.radixdlt.consensus.bft.View)8 BFTHeader (com.radixdlt.consensus.BFTHeader)7 VerifiedVertex (com.radixdlt.consensus.bft.VerifiedVertex)7 Builder (com.radixdlt.consensus.safety.SafetyState.Builder)7 ECDSASignature (com.radixdlt.crypto.ECDSASignature)6 BFTNode (com.radixdlt.consensus.bft.BFTNode)4 ViewUpdate (com.radixdlt.consensus.bft.ViewUpdate)4 HashSigner (com.radixdlt.consensus.HashSigner)3 BFTInsertUpdate (com.radixdlt.consensus.bft.BFTInsertUpdate)3 HashCode (com.google.common.hash.HashCode)2 AbstractModule (com.google.inject.AbstractModule)2 TypeLiteral (com.google.inject.TypeLiteral)2 BFTConfiguration (com.radixdlt.consensus.BFTConfiguration)2 Proposal (com.radixdlt.consensus.Proposal)2 BFTCommittedUpdate (com.radixdlt.consensus.bft.BFTCommittedUpdate)2 BFTHighQCUpdate (com.radixdlt.consensus.bft.BFTHighQCUpdate)2 BFTRebuildUpdate (com.radixdlt.consensus.bft.BFTRebuildUpdate)2