use of org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange in project besu by hyperledger.
the class IbftBlockHeightManagerTest method whenSufficientRoundChangesAreReceivedAProposalMessageIsTransmitted.
@Test
public void whenSufficientRoundChangesAreReceivedAProposalMessageIsTransmitted() {
final ConsensusRoundIdentifier futureRoundIdentifier = createFrom(roundIdentifier, 0, +2);
final RoundChange roundChange = messageFactory.createRoundChange(futureRoundIdentifier, Optional.empty());
final RoundChangeCertificate roundChangCert = new RoundChangeCertificate(singletonList(roundChange.getSignedPayload()));
when(roundChangeManager.appendRoundChangeMessage(any())).thenReturn(Optional.of(singletonList(roundChange)));
when(finalState.isLocalNodeProposerForRound(any())).thenReturn(true);
final IbftBlockHeightManager manager = new IbftBlockHeightManager(headerTestFixture.buildHeader(), finalState, roundChangeManager, roundFactory, clock, messageValidatorFactory, messageFactory);
reset(messageTransmitter);
manager.handleRoundChangePayload(roundChange);
verify(messageTransmitter, times(1)).multicastProposal(eq(futureRoundIdentifier), any(), eq(Optional.of(roundChangCert)));
}
use of org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange in project besu by hyperledger.
the class RoundChangeManagerTest method rejectsInvalidRoundChangeMessage.
@Test
public void rejectsInvalidRoundChangeMessage() {
final RoundChange roundChangeData = makeRoundChangeMessage(nonValidatorKey, ri1);
assertThat(manager.appendRoundChangeMessage(roundChangeData)).isEmpty();
assertThat(manager.roundChangeCache.get(ri1)).isNull();
}
use of org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange in project besu by hyperledger.
the class RoundChangeManagerTest method doesntReachReadyWhenSuppliedWithDifferentRounds.
@Test
public void doesntReachReadyWhenSuppliedWithDifferentRounds() {
final RoundChange roundChangeDataProposer = makeRoundChangeMessage(proposerKey, ri2);
final RoundChange roundChangeDataValidator1 = makeRoundChangeMessage(validator1Key, ri3);
assertThat(manager.appendRoundChangeMessage(roundChangeDataProposer)).isEqualTo(Optional.empty());
assertThat(manager.appendRoundChangeMessage(roundChangeDataValidator1)).isEqualTo(Optional.empty());
assertThat(manager.roundChangeCache.get(ri2).receivedMessages.size()).isEqualTo(1);
assertThat(manager.roundChangeCache.get(ri3).receivedMessages.size()).isEqualTo(1);
}
use of org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange in project besu by hyperledger.
the class RoundChangeManagerTest method becomesReadyAtThreshold.
@Test
public void becomesReadyAtThreshold() {
final RoundChange roundChangeDataProposer = makeRoundChangeMessage(proposerKey, ri2);
final RoundChange roundChangeDataValidator1 = makeRoundChangeMessage(validator1Key, ri2);
assertThat(manager.appendRoundChangeMessage(roundChangeDataProposer)).isEqualTo(Optional.empty());
assertThat(manager.appendRoundChangeMessage(roundChangeDataValidator1).isPresent()).isTrue();
}
use of org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange in project besu by hyperledger.
the class RoundChangeManagerTest method discardsRoundPreviousToThatRequested.
@Test
public void discardsRoundPreviousToThatRequested() {
final RoundChange roundChangeDataProposer = makeRoundChangeMessage(proposerKey, ri1);
final RoundChange roundChangeDataValidator1 = makeRoundChangeMessage(validator1Key, ri2);
final RoundChange roundChangeDataValidator2 = makeRoundChangeMessage(validator2Key, ri3);
assertThat(manager.appendRoundChangeMessage(roundChangeDataProposer)).isEqualTo(Optional.empty());
assertThat(manager.appendRoundChangeMessage(roundChangeDataValidator1)).isEqualTo(Optional.empty());
assertThat(manager.appendRoundChangeMessage(roundChangeDataValidator2)).isEqualTo(Optional.empty());
manager.discardRoundsPriorTo(ri2);
assertThat(manager.roundChangeCache.get(ri1)).isNull();
assertThat(manager.roundChangeCache.get(ri2).receivedMessages.size()).isEqualTo(1);
assertThat(manager.roundChangeCache.get(ri3).receivedMessages.size()).isEqualTo(1);
}
Aggregations