use of com.radixdlt.hotstuff.BFTHeader in project radixdlt by radixdlt.
the class BFTEventReducerTest method when_previous_vote_exists_for_this_view__then_dont_vote.
@Test
public void when_previous_vote_exists_for_this_view__then_dont_vote() {
BFTInsertUpdate bftUpdate = mock(BFTInsertUpdate.class);
BFTHeader header = mock(BFTHeader.class);
when(bftUpdate.getHeader()).thenReturn(header);
when(header.getView()).thenReturn(View.of(3));
ViewUpdate viewUpdate = ViewUpdate.create(View.of(3), mock(HighQC.class), mock(BFTNode.class), this.self);
this.bftEventReducer.processViewUpdate(viewUpdate);
verify(this.pacemaker, times(1)).processViewUpdate(any());
when(safetyRules.getLastVote(View.of(3))).thenReturn(Optional.of(mock(Vote.class)));
this.bftEventReducer.processBFTUpdate(bftUpdate);
verifyNoMoreInteractions(this.voteDispatcher);
verifyNoMoreInteractions(this.noVoteEventDispatcher);
}
use of com.radixdlt.hotstuff.BFTHeader 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);
}
use of com.radixdlt.hotstuff.BFTHeader 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);
}
use of com.radixdlt.hotstuff.BFTHeader in project radixdlt by radixdlt.
the class SafetyRules method constructVoteData.
private static VoteData constructVoteData(VerifiedVertex proposedVertex, BFTHeader proposedHeader) {
final BFTHeader parent = proposedVertex.getParentHeader();
// Add a vertex to commit if creating a quorum for the proposed vertex would
// create three consecutive qcs.
final BFTHeader toCommit;
if (proposedVertex.touchesGenesis() || !proposedVertex.hasDirectParent() || !proposedVertex.parentHasDirectParent()) {
toCommit = null;
} else {
toCommit = proposedVertex.getGrandParentHeader();
}
return new VoteData(proposedHeader, parent, toCommit);
}
use of com.radixdlt.hotstuff.BFTHeader 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());
}
Aggregations