use of org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload in project besu by hyperledger.
the class ProposalValidatorTest method validationFailsIfBlockHashInLatestPreparedMetadataDoesNotMatchProposedBlock.
@Test
public void validationFailsIfBlockHashInLatestPreparedMetadataDoesNotMatchProposedBlock() {
final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
final List<SignedData<RoundChangePayload>> roundChanges = createEmptyRoundChangePayloads(roundItem.roundIdentifier, validators.getNode(0), validators.getNode(1));
final RoundChangePayload illegalPayload = new RoundChangePayload(roundItem.roundIdentifier, Optional.of(new PreparedRoundMetadata(Hash.fromHexStringLenient("0x1"), roundItems.get(ROUND_ID.ZERO).roundIdentifier.getRoundNumber())));
final SignedData<RoundChangePayload> preparedRoundChange = SignedData.create(illegalPayload, validators.getNode(2).getNodeKey().sign(illegalPayload.hashForSignature()));
roundChanges.add(preparedRoundChange);
final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, createPreparePayloads(roundItems.get(ROUND_ID.ZERO).roundIdentifier, Hash.fromHexStringLenient("0x1"), validators.getNode(0), validators.getNode(1), validators.getNode(2)));
assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
use of org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload in project besu by hyperledger.
the class ProposalValidatorTest method validationFailsIfTwoRoundChangesArePreparedOnSameRoundDifferentBlock.
@Test
public void validationFailsIfTwoRoundChangesArePreparedOnSameRoundDifferentBlock() {
final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
final List<SignedData<RoundChangePayload>> roundChanges = createPreparedRoundZeroRoundChanges();
final RoundChangePayload illegalPreparedRoundChangePayload = new RoundChangePayload(roundItem.roundIdentifier, Optional.of(new PreparedRoundMetadata(roundItems.get(ROUND_ID.ONE).block.getHash(), roundItems.get(ROUND_ID.ZERO).roundIdentifier.getRoundNumber())));
final SignedData<RoundChangePayload> preparedRoundChange = SignedData.create(illegalPreparedRoundChangePayload, validators.getNode(3).getNodeKey().sign(illegalPreparedRoundChangePayload.hashForSignature()));
roundChanges.add(preparedRoundChange);
final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, createPreparePayloads(roundItems.get(ROUND_ID.ZERO).roundIdentifier, Hash.fromHexStringLenient("0x1"), validators.getNode(0), validators.getNode(1), validators.getNode(2)));
assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
use of org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload in project besu by hyperledger.
the class ProposalValidatorTest method createPreparedRoundZeroRoundChanges.
private List<SignedData<RoundChangePayload>> createPreparedRoundZeroRoundChanges() {
final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
final List<SignedData<RoundChangePayload>> roundChanges = createEmptyRoundChangePayloads(roundItem.roundIdentifier, validators.getNode(0), validators.getNode(1));
final RoundChangePayload preparedRoundChangePayload = new RoundChangePayload(roundItem.roundIdentifier, Optional.of(new PreparedRoundMetadata(roundItems.get(ROUND_ID.ZERO).block.getHash(), roundItems.get(ROUND_ID.ZERO).roundIdentifier.getRoundNumber())));
final SignedData<RoundChangePayload> preparedRoundChange = SignedData.create(preparedRoundChangePayload, validators.getNode(2).getNodeKey().sign(preparedRoundChangePayload.hashForSignature()));
roundChanges.add(preparedRoundChange);
return roundChanges;
}
use of org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload in project besu by hyperledger.
the class RoundChangePayloadValidatorTest method roundChangeWithMatchingTargetAndPrepareFails.
@Test
public void roundChangeWithMatchingTargetAndPrepareFails() {
final RoundChangePayload payload = new RoundChangePayload(new ConsensusRoundIdentifier(chainHeight, 1), Optional.of(new PreparedRoundMetadata(preparedBlockHash, 1)));
final SignedData<RoundChangePayload> signedPayload = createSignedPayload(payload, validators.getNode(0).getNodeKey());
assertThat(messageValidator.validate(signedPayload)).isFalse();
}
use of org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload in project besu by hyperledger.
the class RoundChangePayloadValidatorTest method roundChangeForFutureHeightFails.
@Test
public void roundChangeForFutureHeightFails() {
final RoundChangePayload payload = new RoundChangePayload(new ConsensusRoundIdentifier(chainHeight + 1, 1), Optional.of(new PreparedRoundMetadata(preparedBlockHash, 0)));
final SignedData<RoundChangePayload> signedPayload = createSignedPayload(payload, validators.getNode(0).getNodeKey());
assertThat(messageValidator.validate(signedPayload)).isFalse();
}
Aggregations