Search in sources :

Example 26 with Vote

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

the class SafetyRulesTest method when_vote_on_proposal_after_genesis__then_returned_vote_has_no_commit.

@Test
public void when_vote_on_proposal_after_genesis__then_returned_vote_has_no_commit() {
    when(safetyState.getLastVotedView()).thenReturn(View.of(0));
    when(safetyState.getLockedView()).thenReturn(View.of(0));
    when(safetyState.toBuilder()).thenReturn(mock(Builder.class));
    VerifiedVertex vertex = mock(VerifiedVertex.class);
    when(vertex.hasDirectParent()).thenReturn(true);
    when(vertex.touchesGenesis()).thenReturn(true);
    when(vertex.parentHasDirectParent()).thenReturn(true);
    when(vertex.getView()).thenReturn(View.of(1));
    BFTHeader parent = mock(BFTHeader.class);
    when(parent.getView()).thenReturn(View.of(0));
    when(vertex.getParentHeader()).thenReturn(parent);
    BFTHeader grandParent = mock(BFTHeader.class);
    when(grandParent.getView()).thenReturn(mock(View.class));
    when(vertex.getGrandParentHeader()).thenReturn(grandParent);
    BFTHeader header = mock(BFTHeader.class);
    Optional<Vote> voteMaybe = safetyRules.voteFor(vertex, header, 1L, mock(HighQC.class));
    assertThat(voteMaybe).isNotEmpty();
    Vote vote = voteMaybe.get();
    assertThat(vote.getVoteData().getProposed()).isEqualTo(header);
    assertThat(vote.getVoteData().getParent()).isEqualTo(parent);
    assertThat(vote.getVoteData().getCommitted()).isEmpty();
}
Also used : VerifiedVertex(com.radixdlt.hotstuff.bft.VerifiedVertex) HighQC(com.radixdlt.hotstuff.HighQC) BFTHeader(com.radixdlt.hotstuff.BFTHeader) Vote(com.radixdlt.hotstuff.Vote) Builder(com.radixdlt.hotstuff.safety.SafetyState.Builder) View(com.radixdlt.hotstuff.bft.View) Test(org.junit.Test)

Aggregations

Vote (com.radixdlt.hotstuff.Vote)26 Test (org.junit.Test)19 HighQC (com.radixdlt.hotstuff.HighQC)11 View (com.radixdlt.hotstuff.bft.View)9 BFTHeader (com.radixdlt.hotstuff.BFTHeader)8 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)7 Builder (com.radixdlt.hotstuff.safety.SafetyState.Builder)7 ECDSASignature (com.radixdlt.crypto.ECDSASignature)6 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)6 HashCode (com.google.common.hash.HashCode)4 ViewUpdate (com.radixdlt.hotstuff.bft.ViewUpdate)4 HashSigner (com.radixdlt.hotstuff.HashSigner)3 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)3 BFTInsertUpdate (com.radixdlt.hotstuff.bft.BFTInsertUpdate)3 AbstractModule (com.google.inject.AbstractModule)2 TypeLiteral (com.google.inject.TypeLiteral)2 SystemCounters (com.radixdlt.counters.SystemCounters)2 Hasher (com.radixdlt.crypto.Hasher)2 EventDispatcher (com.radixdlt.environment.EventDispatcher)2 RemoteEventDispatcher (com.radixdlt.environment.RemoteEventDispatcher)2