use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.
the class ReceivedFutureProposalTest method proposalWithPrepareCertificateResultsInNewRoundStartingWithExpectedBlock.
@Test
public void proposalWithPrepareCertificateResultsInNewRoundStartingWithExpectedBlock() {
final Block initialBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
final Block reproposedBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
final PreparedCertificate preparedRoundArtifacts = createValidPreparedCertificate(context, roundId, initialBlock);
final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
final List<SignedData<PreparePayload>> prepares = peers.createSignedPreparePayloadOfAllPeers(roundId, initialBlock.getHash());
final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
nextProposer.injectProposalForFutureRound(nextRoundId, roundChanges, prepares, reproposedBlock);
peers.verifyMessagesReceived(localNodeMessageFactory.createPrepare(nextRoundId, reproposedBlock.getHash()));
}
use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.
the class ReceivedFutureProposalTest method futureProposalWithInsufficientPreparesDoesNotTriggerNextRound.
@Test
public void futureProposalWithInsufficientPreparesDoesNotTriggerNextRound() {
final Block initialBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
final Block reproposedBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
final PreparedCertificate preparedRoundArtifacts = createValidPreparedCertificate(context, roundId, initialBlock);
final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
final List<SignedData<PreparePayload>> prepares = peers.createSignedPreparePayloadOfAllPeers(roundId, initialBlock.getHash());
final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
nextProposer.injectProposalForFutureRound(nextRoundId, roundChanges, prepares.subList(0, 2), reproposedBlock);
peers.verifyNoMessagesReceived();
}
use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.
the class ReceivedFutureProposalTest method proposalWithEmptyPrepareCertificatesOfferNewBlock.
@Test
public void proposalWithEmptyPrepareCertificatesOfferNewBlock() {
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(targetRound);
final ValidatorPeer nextProposer = context.roundSpecificPeers(targetRound).getProposer();
final Block blockToPropose = context.createBlockForProposalFromChainHead(15, nextProposer.getNodeAddress());
nextProposer.injectProposalForFutureRound(targetRound, roundChanges, Collections.emptyList(), blockToPropose);
final Prepare expectedPrepare = localNodeMessageFactory.createPrepare(targetRound, blockToPropose.getHash());
peers.verifyMessagesReceived(expectedPrepare);
}
use of org.hyperledger.besu.consensus.qbft.support.ValidatorPeer in project besu by hyperledger.
the class ReceivedFutureProposalTest method futureProposalWithInvalidPrepareDoesNotTriggerNextRound.
@Test
public void futureProposalWithInvalidPrepareDoesNotTriggerNextRound() {
final Block initialBlock = context.createBlockForProposalFromChainHead(15, peers.getProposer().getNodeAddress());
final Block reproposedBlock = context.createBlockForProposalFromChainHead(15);
final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1);
final PreparedCertificate preparedRoundArtifacts = createValidPreparedCertificate(context, roundId, initialBlock);
final List<SignedData<RoundChangePayload>> roundChanges = peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtifacts);
List<SignedData<PreparePayload>> prepares = peers.createSignedPreparePayloadOfAllPeers(roundId, initialBlock.getHash());
prepares = prepares.stream().filter(p -> !p.getAuthor().equals(peers.getFirstNonProposer().getNodeAddress())).collect(Collectors.toList());
final SignedData<PreparePayload> invalidPrepare = peers.getFirstNonProposer().getMessageFactory().createPrepare(nextRoundId, initialBlock.getHash()).getSignedPayload();
prepares.add(invalidPrepare);
final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer();
nextProposer.injectProposalForFutureRound(nextRoundId, roundChanges, prepares, reproposedBlock);
peers.verifyNoMessagesReceived();
}
use of org.hyperledger.besu.consensus.qbft.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