Search in sources :

Example 1 with QuorumCertificate

use of com.radixdlt.hotstuff.QuorumCertificate 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.hotstuff.HighQC) Vote(com.radixdlt.hotstuff.Vote) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) Test(org.junit.Test)

Example 2 with QuorumCertificate

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

the class VerifiedVertexStoreStateCreationTest method creating_vertex_store_with_root_not_committed_should_fail.

@Test
public void creating_vertex_store_with_root_not_committed_should_fail() {
    BFTHeader genesisHeader = new BFTHeader(View.of(0), genesisHash, mock(LedgerHeader.class));
    VoteData voteData = new VoteData(genesisHeader, genesisHeader, null);
    QuorumCertificate badRootQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    assertThatThrownBy(() -> VerifiedVertexStoreState.create(HighQC.from(badRootQC), genesisVertex, Optional.empty(), hasher)).isInstanceOf(IllegalStateException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) BFTHeader(com.radixdlt.hotstuff.BFTHeader) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VoteData(com.radixdlt.hotstuff.VoteData) Test(org.junit.Test)

Example 3 with QuorumCertificate

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

the class VerifiedVertexStoreStateCreationTest method creating_vertex_store_with_committed_qc_not_matching_vertex_should_fail.

@Test
public void creating_vertex_store_with_committed_qc_not_matching_vertex_should_fail() {
    BFTHeader genesisHeader = new BFTHeader(View.of(0), genesisHash, mock(LedgerHeader.class));
    BFTHeader otherHeader = new BFTHeader(View.of(0), HashUtils.random256(), mock(LedgerHeader.class));
    VoteData voteData = new VoteData(genesisHeader, genesisHeader, otherHeader);
    QuorumCertificate badRootQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    assertThatThrownBy(() -> VerifiedVertexStoreState.create(HighQC.from(badRootQC), genesisVertex, Optional.empty(), hasher)).isInstanceOf(IllegalStateException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) BFTHeader(com.radixdlt.hotstuff.BFTHeader) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) VoteData(com.radixdlt.hotstuff.VoteData) Test(org.junit.Test)

Example 4 with QuorumCertificate

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

the class UnverifiedVertexSerializeTest method get.

private static UnverifiedVertex get() {
    View view = View.of(1234567891L);
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    BFTHeader header = new BFTHeader(view, HashUtils.random256(), ledgerHeader);
    BFTHeader parent = new BFTHeader(View.of(1234567890L), HashUtils.random256(), ledgerHeader);
    VoteData voteData = new VoteData(header, parent, null);
    QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    var txn = Txn.create(new byte[] { 0, 1, 2, 3 });
    return UnverifiedVertex.create(qc, view, List.of(txn), BFTNode.random());
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTHeader(com.radixdlt.hotstuff.BFTHeader) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) View(com.radixdlt.hotstuff.bft.View) VoteData(com.radixdlt.hotstuff.VoteData)

Example 5 with QuorumCertificate

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

the class VoteSerializeTest method get.

private static Vote get() {
    View view = View.of(1234567891L);
    HashCode id = HashUtils.random256();
    LedgerHeader ledgerHeader = LedgerHeaderMock.get();
    BFTHeader header = new BFTHeader(view, id, ledgerHeader);
    BFTHeader parent = new BFTHeader(View.of(1234567890L), HashUtils.random256(), ledgerHeader);
    VoteData voteData = new VoteData(header, parent, null);
    BFTNode author = BFTNode.create(ECKeyPair.generateNew().getPublicKey());
    QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    HighQC highQC = HighQC.from(qc, qc, Optional.empty());
    return new Vote(author, voteData, 123456L, ECDSASignature.zeroSignature(), highQC, Optional.empty());
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) HighQC(com.radixdlt.hotstuff.HighQC) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTHeader(com.radixdlt.hotstuff.BFTHeader) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) Vote(com.radixdlt.hotstuff.Vote) HashCode(com.google.common.hash.HashCode) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) View(com.radixdlt.hotstuff.bft.View) VoteData(com.radixdlt.hotstuff.VoteData)

Aggregations

QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)25 HighQC (com.radixdlt.hotstuff.HighQC)14 LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)13 Test (org.junit.Test)13 BFTHeader (com.radixdlt.hotstuff.BFTHeader)12 TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)12 VoteData (com.radixdlt.hotstuff.VoteData)12 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)9 VerifiedVertex (com.radixdlt.hotstuff.bft.VerifiedVertex)8 View (com.radixdlt.hotstuff.bft.View)8 UnverifiedVertex (com.radixdlt.hotstuff.UnverifiedVertex)7 EventDispatcher (com.radixdlt.environment.EventDispatcher)6 Before (org.junit.Before)6 HashCode (com.google.common.hash.HashCode)5 Txn (com.radixdlt.atom.Txn)5 ViewUpdate (com.radixdlt.hotstuff.bft.ViewUpdate)5 Hasher (com.radixdlt.crypto.Hasher)4 Ledger (com.radixdlt.hotstuff.Ledger)4 Proposal (com.radixdlt.hotstuff.Proposal)4 VerifiedVertexStoreState (com.radixdlt.hotstuff.bft.VerifiedVertexStoreState)4