use of com.radixdlt.hotstuff.UnverifiedVertex in project radixdlt by radixdlt.
the class EpochManagerTest method should_not_send_consensus_messages_if_not_part_of_new_epoch.
@Test
public void should_not_send_consensus_messages_if_not_part_of_new_epoch() {
// Arrange
epochManager.start();
BFTValidatorSet nextValidatorSet = BFTValidatorSet.from(Stream.of(BFTValidator.from(BFTNode.random(), UInt256.ONE)));
var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
LedgerHeader header = LedgerHeader.genesis(accumulatorState, nextValidatorSet, 0);
UnverifiedVertex genesisVertex = UnverifiedVertex.createGenesis(header);
VerifiedVertex verifiedGenesisVertex = new VerifiedVertex(genesisVertex, hasher.hash(genesisVertex));
LedgerHeader nextLedgerHeader = LedgerHeader.create(header.getEpoch() + 1, View.genesis(), header.getAccumulatorState(), header.timestamp());
var genesisQC = QuorumCertificate.ofGenesis(verifiedGenesisVertex, nextLedgerHeader);
var proposerElection = new WeightedRotatingLeaders(nextValidatorSet);
var bftConfiguration = new BFTConfiguration(proposerElection, nextValidatorSet, VerifiedVertexStoreState.create(HighQC.from(genesisQC), verifiedGenesisVertex, Optional.empty(), hasher));
LedgerProof proof = mock(LedgerProof.class);
when(proof.getEpoch()).thenReturn(header.getEpoch() + 1);
var epochChange = new EpochChange(proof, bftConfiguration);
var ledgerUpdate = new LedgerUpdate(mock(VerifiedTxnsAndProof.class), ImmutableClassToInstanceMap.of(EpochChange.class, epochChange));
// Act
epochManager.epochsLedgerUpdateEventProcessor().process(ledgerUpdate);
// Assert
verify(proposalDispatcher, never()).dispatch(any(Iterable.class), argThat(p -> p.getEpoch() == epochChange.getEpoch()));
verify(voteDispatcher, never()).dispatch(any(BFTNode.class), any());
}
use of com.radixdlt.hotstuff.UnverifiedVertex in project radixdlt by radixdlt.
the class StateComputerLedgerTest method should_accumulate_when_next_command_valid.
@Test
public void should_accumulate_when_next_command_valid() {
// Arrange
genesisIsEndOfEpoch(false);
when(stateComputer.prepare(any(), any(), anyLong())).thenReturn(new StateComputerResult(ImmutableList.of(successfulNextCommand), ImmutableMap.of()));
// Act
var unverifiedVertex = UnverifiedVertex.create(genesisQC, View.of(1), List.of(nextTxn), BFTNode.random());
var proposedVertex = new VerifiedVertex(unverifiedVertex, hasher.hash(unverifiedVertex));
Optional<PreparedVertex> nextPrepared = sut.prepare(new LinkedList<>(), proposedVertex);
// Assert
assertThat(nextPrepared).hasValueSatisfying(x -> assertThat(x.getLedgerHeader().isEndOfEpoch()).isFalse());
assertThat(nextPrepared.flatMap(x -> accumulatorVerifier.verifyAndGetExtension(ledgerHeader.getAccumulatorState(), List.of(nextTxn), txn -> txn.getId().asHashCode(), x.getLedgerHeader().getAccumulatorState()))).contains(List.of(nextTxn));
}
use of com.radixdlt.hotstuff.UnverifiedVertex in project radixdlt by radixdlt.
the class GetVerticesResponseMessageSerializeTest method get.
private static GetVerticesResponseMessage get() {
LedgerHeader ledgerHeader = LedgerHeaderMock.get();
UnverifiedVertex genesisVertex = UnverifiedVertex.createGenesis(ledgerHeader);
return new GetVerticesResponseMessage(ImmutableList.of(genesisVertex));
}
use of com.radixdlt.hotstuff.UnverifiedVertex in project radixdlt by radixdlt.
the class DifferentTimestampsCauseTimeoutTest method mutateProposal.
private Proposal mutateProposal(Proposal p, int destination) {
QuorumCertificate committedQC = p.highQC().highestCommittedQC();
UnverifiedVertex vertex = p.getVertex();
ECDSASignature signature = p.getSignature();
return new Proposal(mutateVertex(vertex, destination), committedQC, signature, Optional.empty());
}
Aggregations