use of org.hyperledger.besu.consensus.ibft.support.ValidatorPeer in project besu by hyperledger.
the class ReceivedFutureProposalTest method proposalMessageForPriorRoundIsNotActioned.
@Test
public void proposalMessageForPriorRoundIsNotActioned() {
// first move to a future round, then inject a proposal for a prior round, local node
// should send no messages.
final ConsensusRoundIdentifier futureRound = new ConsensusRoundIdentifier(1, 2);
peers.roundChange(futureRound);
final ConsensusRoundIdentifier interimRound = new ConsensusRoundIdentifier(1, 1);
final List<SignedData<RoundChangePayload>> roundChangePayloads = peers.createSignedRoundChangePayload(interimRound);
final ValidatorPeer interimRoundProposer = context.roundSpecificPeers(interimRound).getProposer();
interimRoundProposer.injectProposalForFutureRound(interimRound, new RoundChangeCertificate(roundChangePayloads), context.createBlockForProposalFromChainHead(1, 30));
peers.verifyNoMessagesReceived();
}
use of org.hyperledger.besu.consensus.ibft.support.ValidatorPeer in project besu by hyperledger.
the class ReceivedFutureProposalTest method receiveRoundStateIsNotLostIfASecondProposalMessageIsReceivedForCurrentRound.
@Test
public void receiveRoundStateIsNotLostIfASecondProposalMessageIsReceivedForCurrentRound() {
final Block initialBlock = context.createBlockForProposalFromChainHead(0, 15);
final Block reproposedBlock = context.createBlockForProposalFromChainHead(1, 15);
final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
final PreparedRoundArtifacts preparedRoundArtifacts = createValidPreparedRoundArtifacts(context, roundId, initialBlock);
final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
final RoundSpecificPeers nextRoles = context.roundSpecificPeers(nextRoundId);
final ValidatorPeer nextProposer = nextRoles.getProposer();
nextProposer.injectProposalForFutureRound(nextRoundId, new RoundChangeCertificate(roundChanges), reproposedBlock);
peers.verifyMessagesReceived(localNodeMessageFactory.createPrepare(nextRoundId, reproposedBlock.getHash()));
// Inject a prepare, then re-inject the proposal - then ensure only a single prepare is enough
// to trigger a Commit transmission from the local node
nextRoles.getNonProposing(0).injectPrepare(nextRoundId, reproposedBlock.getHash());
nextProposer.injectProposalForFutureRound(nextRoundId, new RoundChangeCertificate(roundChanges), reproposedBlock);
peers.verifyNoMessagesReceived();
nextRoles.getNonProposing(1).injectPrepare(nextRoundId, reproposedBlock.getHash());
final Commit expectedCommit = new Commit(IntegrationTestHelpers.createSignedCommitPayload(nextRoundId, reproposedBlock, context.getLocalNodeParams().getNodeKey()));
peers.verifyMessagesReceived(expectedCommit);
}
use of org.hyperledger.besu.consensus.ibft.support.ValidatorPeer in project besu by hyperledger.
the class ReceivedFutureProposalTest method proposalWithEmptyPrepareCertificatesOfferNewBlock.
@Test
public void proposalWithEmptyPrepareCertificatesOfferNewBlock() {
final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
final Block blockToPropose = context.createBlockForProposalFromChainHead(nextRoundId.getRoundNumber(), 15);
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(targetRound);
final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
nextProposer.injectProposalForFutureRound(targetRound, new RoundChangeCertificate(roundChanges), blockToPropose);
final Prepare expectedPrepare = localNodeMessageFactory.createPrepare(targetRound, blockToPropose.getHash());
peers.verifyMessagesReceived(expectedPrepare);
}
use of org.hyperledger.besu.consensus.ibft.support.ValidatorPeer in project besu by hyperledger.
the class RoundChangeTest method multipleRoundChangeMessagesFromSamePeerDoesNotTriggerRoundChange.
@Test
public void multipleRoundChangeMessagesFromSamePeerDoesNotTriggerRoundChange() {
// Note: Round-3 is the next round for which the local node is Proposer
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 4);
final ValidatorPeer transmitter = peers.getNonProposing(0);
for (int i = 0; i < BftHelpers.calculateRequiredValidatorQuorum(NETWORK_SIZE); i++) {
transmitter.injectRoundChange(targetRound, empty());
}
peers.verifyNoMessagesReceived();
}
use of org.hyperledger.besu.consensus.ibft.support.ValidatorPeer in project besu by hyperledger.
the class SpuriousBehaviourTest method nonValidatorsCannotTriggerResponses.
@Test
public void nonValidatorsCannotTriggerResponses() {
final NodeKey nonValidatorNodeKey = NodeKeyUtils.generate();
final NodeParams nonValidatorParams = new NodeParams(Util.publicKeyToAddress(nonValidatorNodeKey.getPublicKey()), nonValidatorNodeKey);
final ValidatorPeer nonvalidator = new ValidatorPeer(nonValidatorParams, new MessageFactory(nonValidatorParams.getNodeKey()), context.getEventMultiplexer());
nonvalidator.injectProposal(new ConsensusRoundIdentifier(1, 0), proposedBlock);
peers.verifyNoMessagesReceived();
}
Aggregations