Search in sources :

Example 1 with RoundChangeMessageData

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());
}
Also used : RoundChangeMessageData(org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) Prepare(org.hyperledger.besu.consensus.ibft.messagewrappers.Prepare) PreparedCertificate(org.hyperledger.besu.consensus.ibft.payload.PreparedCertificate) RoundChangeMessageData(org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData) RoundExpiry(org.hyperledger.besu.consensus.common.bft.events.RoundExpiry) Test(org.junit.Test)

Example 2 with RoundChangeMessageData

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());
    }
}
Also used : RoundChange(org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange) SecurityModuleException(org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleException) RoundChangeMessageData(org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData)

Aggregations

RoundChangeMessageData (org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData)2 RoundExpiry (org.hyperledger.besu.consensus.common.bft.events.RoundExpiry)1 Prepare (org.hyperledger.besu.consensus.ibft.messagewrappers.Prepare)1 RoundChange (org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange)1 PreparedCertificate (org.hyperledger.besu.consensus.ibft.payload.PreparedCertificate)1 MessageData (org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData)1 SecurityModuleException (org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleException)1 Test (org.junit.Test)1