use of com.radixdlt.hotstuff.QuorumCertificate 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());
}
use of com.radixdlt.hotstuff.QuorumCertificate in project radixdlt by radixdlt.
the class MessageCentralValidatorSyncTest method when_send_error_response__then_message_central_will_send_error_response.
@Test
public void when_send_error_response__then_message_central_will_send_error_response() {
QuorumCertificate qc = mock(QuorumCertificate.class);
HighQC highQC = mock(HighQC.class);
when(highQC.highestQC()).thenReturn(qc);
when(highQC.highestCommittedQC()).thenReturn(qc);
BFTNode node = mock(BFTNode.class);
ECPublicKey ecPublicKey = mock(ECPublicKey.class);
when(node.getKey()).thenReturn(ecPublicKey);
final var request = new GetVerticesRequest(HashUtils.random256(), 3);
sync.verticesErrorResponseDispatcher().dispatch(node, new GetVerticesErrorResponse(highQC, request));
verify(messageCentral, times(1)).send(eq(NodeId.fromPublicKey(ecPublicKey)), any(GetVerticesErrorResponseMessage.class));
}
use of com.radixdlt.hotstuff.QuorumCertificate in project radixdlt by radixdlt.
the class ConsensusModuleTest method createNextVertex.
private Pair<QuorumCertificate, VerifiedVertex> createNextVertex(QuorumCertificate parent, ECKeyPair proposerKeyPair, Txn txn) {
final var proposerBftNode = BFTNode.create(proposerKeyPair.getPublicKey());
var unverifiedVertex = UnverifiedVertex.create(parent, View.of(1), List.of(txn), proposerBftNode);
var hash = hasher.hash(unverifiedVertex);
var verifiedVertex = new VerifiedVertex(unverifiedVertex, hash);
var next = new BFTHeader(View.of(1), verifiedVertex.getId(), LedgerHeader.create(1, View.of(1), new AccumulatorState(1, HashUtils.zero256()), 1));
final var voteData = new VoteData(next, parent.getProposed(), parent.getParent());
final var timestamp = 1;
final var voteDataHash = Vote.getHashOfData(hasher, voteData, timestamp);
final var qcSignature = proposerKeyPair.sign(voteDataHash);
var unsyncedQC = new QuorumCertificate(voteData, new TimestampedECDSASignatures(Map.of(proposerBftNode, TimestampedECDSASignature.from(timestamp, qcSignature))));
return Pair.of(unsyncedQC, verifiedVertex);
}
use of com.radixdlt.hotstuff.QuorumCertificate in project radixdlt by radixdlt.
the class VertexStoreTest method adding_a_qc_with_commit_should_commit_vertices_to_ledger.
@Test
public void adding_a_qc_with_commit_should_commit_vertices_to_ledger() {
// Arrange
final var vertices = Stream.generate(this.nextVertex).limit(4).toList();
sut.insertVertex(vertices.get(0));
sut.insertVertex(vertices.get(1));
sut.insertVertex(vertices.get(2));
// Act
QuorumCertificate qc = vertices.get(3).getQC();
boolean success = sut.addQC(qc);
// Assert
assertThat(success).isTrue();
assertThat(sut.highQC().highestQC()).isEqualTo(qc);
assertThat(sut.highQC().highestCommittedQC()).isEqualTo(qc);
assertThat(sut.getVertices(vertices.get(2).getId(), 3)).hasValue(ImmutableList.of(vertices.get(2), vertices.get(1), vertices.get(0)));
verify(committedSender, times(1)).dispatch(argThat(u -> u.committed().size() == 1 && u.committed().get(0).getVertex().equals(vertices.get(0))));
}
use of com.radixdlt.hotstuff.QuorumCertificate in project radixdlt by radixdlt.
the class VertexStoreTest method adding_a_qc_should_update_highest_qc.
@Test
public void adding_a_qc_should_update_highest_qc() {
// Arrange
final var vertices = Stream.generate(this.nextVertex).limit(4).toList();
sut.insertVertex(vertices.get(0));
// Act
QuorumCertificate qc = vertices.get(1).getQC();
sut.addQC(qc);
// Assert
assertThat(sut.highQC().highestQC()).isEqualTo(qc);
assertThat(sut.highQC().highestCommittedQC()).isEqualTo(rootQC);
}
Aggregations