use of org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData in project besu by hyperledger.
the class IbftBlockHeightManagerTest method preparedCertificateIncludedInRoundChangeMessageOnRoundTimeoutExpired.
@Test
public void preparedCertificateIncludedInRoundChangeMessageOnRoundTimeoutExpired() {
final IbftBlockHeightManager manager = new IbftBlockHeightManager(headerTestFixture.buildHeader(), finalState, roundChangeManager, roundFactory, clock, messageValidatorFactory, messageFactory);
// Trigger a Proposal creation.
manager.handleBlockTimerExpiry(roundIdentifier);
final Prepare firstPrepare = validatorMessageFactory.get(0).createPrepare(roundIdentifier, Hash.fromHexStringLenient("0"));
final Prepare secondPrepare = validatorMessageFactory.get(1).createPrepare(roundIdentifier, Hash.fromHexStringLenient("0"));
manager.handlePreparePayload(firstPrepare);
manager.handlePreparePayload(secondPrepare);
manager.roundExpired(new RoundExpiry(roundIdentifier));
verify(validatorMulticaster, times(1)).send(sentMessageArgCaptor.capture());
final MessageData capturedMessageData = sentMessageArgCaptor.getValue();
assertThat(capturedMessageData).isInstanceOf(RoundChangeMessageData.class);
final RoundChangeMessageData roundChange = (RoundChangeMessageData) capturedMessageData;
Optional<PreparedCertificate> preparedCert = roundChange.decode().getPreparedCertificate();
Assertions.assertThat(preparedCert).isNotEmpty();
assertThat(preparedCert.get().getPreparePayloads()).containsOnly(firstPrepare.getSignedPayload(), secondPrepare.getSignedPayload());
}
use of org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData in project besu by hyperledger.
the class IbftMessageTransmitter method multicastRoundChange.
public void multicastRoundChange(final ConsensusRoundIdentifier roundIdentifier, final Optional<PreparedRoundArtifacts> preparedRoundArtifacts) {
try {
final RoundChange data = messageFactory.createRoundChange(roundIdentifier, preparedRoundArtifacts);
final RoundChangeMessageData message = RoundChangeMessageData.create(data);
multicaster.send(message);
} catch (final SecurityModuleException e) {
LOG.warn("Failed to generate signature for RoundChange (not sent): {} ", e.getMessage());
}
}
Aggregations