Search in sources :

Example 11 with HighQC

use of com.radixdlt.consensus.HighQC 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);
}
Also used : HighQC(com.radixdlt.consensus.HighQC) Vote(com.radixdlt.consensus.Vote) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) Test(org.junit.Test)

Aggregations

HighQC (com.radixdlt.consensus.HighQC)11 QuorumCertificate (com.radixdlt.consensus.QuorumCertificate)10 BFTNode (com.radixdlt.consensus.bft.BFTNode)8 ViewUpdate (com.radixdlt.consensus.bft.ViewUpdate)8 View (com.radixdlt.consensus.bft.View)7 Test (org.junit.Test)7 EventDispatcher (com.radixdlt.environment.EventDispatcher)6 Before (org.junit.Before)6 Vote (com.radixdlt.consensus.Vote)5 VerifiedVertex (com.radixdlt.consensus.bft.VerifiedVertex)5 BFTInsertUpdate (com.radixdlt.consensus.bft.BFTInsertUpdate)4 AbstractModule (com.google.inject.AbstractModule)3 TypeLiteral (com.google.inject.TypeLiteral)3 BFTConfiguration (com.radixdlt.consensus.BFTConfiguration)3 HashSigner (com.radixdlt.consensus.HashSigner)3 Proposal (com.radixdlt.consensus.Proposal)3 BFTCommittedUpdate (com.radixdlt.consensus.bft.BFTCommittedUpdate)3 BFTHighQCUpdate (com.radixdlt.consensus.bft.BFTHighQCUpdate)3 TypedMocks.rmock (com.radixdlt.utils.TypedMocks.rmock)3 Mockito.times (org.mockito.Mockito.times)3