Search in sources :

Example 1 with VoteData

use of com.radixdlt.consensus.VoteData 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.consensus.TimestampedECDSASignatures) BFTHeader(com.radixdlt.consensus.BFTHeader) LedgerHeader(com.radixdlt.consensus.LedgerHeader) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) VoteData(com.radixdlt.consensus.VoteData) Test(org.junit.Test)

Example 2 with VoteData

use of com.radixdlt.consensus.VoteData 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.consensus.TimestampedECDSASignatures) BFTHeader(com.radixdlt.consensus.BFTHeader) LedgerHeader(com.radixdlt.consensus.LedgerHeader) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) VoteData(com.radixdlt.consensus.VoteData) Test(org.junit.Test)

Example 3 with VoteData

use of com.radixdlt.consensus.VoteData 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.consensus.TimestampedECDSASignatures) LedgerHeader(com.radixdlt.consensus.LedgerHeader) BFTHeader(com.radixdlt.consensus.BFTHeader) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) View(com.radixdlt.consensus.bft.View) VoteData(com.radixdlt.consensus.VoteData)

Example 4 with VoteData

use of com.radixdlt.consensus.VoteData 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.consensus.TimestampedECDSASignatures) HighQC(com.radixdlt.consensus.HighQC) LedgerHeader(com.radixdlt.consensus.LedgerHeader) BFTHeader(com.radixdlt.consensus.BFTHeader) BFTNode(com.radixdlt.consensus.bft.BFTNode) Vote(com.radixdlt.consensus.Vote) HashCode(com.google.common.hash.HashCode) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) View(com.radixdlt.consensus.bft.View) VoteData(com.radixdlt.consensus.VoteData)

Example 5 with VoteData

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

the class ProposalSerializeTest method get.

private static Proposal 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);
    QuorumCertificate qc = new QuorumCertificate(voteData, new TimestampedECDSASignatures());
    var txn = Txn.create(new byte[] { 0, 1, 2, 3 });
    // add a particle to ensure atom is valid and has at least one shard
    BFTNode author = BFTNode.create(ECKeyPair.generateNew().getPublicKey());
    UnverifiedVertex vertex = UnverifiedVertex.create(qc, view, List.of(txn), author);
    return new Proposal(vertex, qc, ECDSASignature.zeroSignature(), Optional.empty());
}
Also used : TimestampedECDSASignatures(com.radixdlt.consensus.TimestampedECDSASignatures) LedgerHeader(com.radixdlt.consensus.LedgerHeader) BFTHeader(com.radixdlt.consensus.BFTHeader) BFTNode(com.radixdlt.consensus.bft.BFTNode) HashCode(com.google.common.hash.HashCode) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) View(com.radixdlt.consensus.bft.View) VoteData(com.radixdlt.consensus.VoteData) UnverifiedVertex(com.radixdlt.consensus.UnverifiedVertex) Proposal(com.radixdlt.consensus.Proposal)

Aggregations

VoteData (com.radixdlt.consensus.VoteData)12 BFTHeader (com.radixdlt.consensus.BFTHeader)10 QuorumCertificate (com.radixdlt.consensus.QuorumCertificate)9 TimestampedECDSASignatures (com.radixdlt.consensus.TimestampedECDSASignatures)9 LedgerHeader (com.radixdlt.consensus.LedgerHeader)7 View (com.radixdlt.consensus.bft.View)4 HashCode (com.google.common.hash.HashCode)3 Test (org.junit.Test)3 Vote (com.radixdlt.consensus.Vote)2 BFTNode (com.radixdlt.consensus.bft.BFTNode)2 HighQC (com.radixdlt.consensus.HighQC)1 Ledger (com.radixdlt.consensus.Ledger)1 Proposal (com.radixdlt.consensus.Proposal)1 UnverifiedVertex (com.radixdlt.consensus.UnverifiedVertex)1 VerifiedVertex (com.radixdlt.consensus.bft.VerifiedVertex)1 ECDSASignature (com.radixdlt.crypto.ECDSASignature)1 EventDispatcher (com.radixdlt.environment.EventDispatcher)1 AccumulatorState (com.radixdlt.ledger.AccumulatorState)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Before (org.junit.Before)1