use of org.hyperledger.besu.consensus.common.bft.payload.SignedData in project besu by hyperledger.
the class ProposalValidatorTest method validationFailsIfPiggybackedRoundChangePayloadHasDuplicatedAuthors.
@Test
public void validationFailsIfPiggybackedRoundChangePayloadHasDuplicatedAuthors() {
final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
final List<SignedData<RoundChangePayload>> roundChanges = createEmptyRoundChangePayloads(roundItem.roundIdentifier, validators.getNode(0), validators.getNode(1), validators.getNode(1));
final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, emptyList());
assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
use of org.hyperledger.besu.consensus.common.bft.payload.SignedData 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.common.bft.payload.SignedData in project besu by hyperledger.
the class ProposalValidatorTest method validationFailsIfPiggybackedPreparePayloadIsFromNonValidator.
@Test
public void validationFailsIfPiggybackedPreparePayloadIsFromNonValidator() {
final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
final List<SignedData<RoundChangePayload>> roundChanges = createPreparedRoundZeroRoundChanges();
final QbftNode nonValidator = QbftNode.create();
final Proposal proposal = validators.getMessageFactory(0).createProposal(roundItem.roundIdentifier, roundItem.block, roundChanges, createPreparePayloads(roundItems.get(ROUND_ID.ZERO).roundIdentifier, roundItems.get(ROUND_ID.ZERO).block.getHash(), validators.getNode(0), validators.getNode(1), nonValidator));
assertThat(roundItem.messageValidator.validate(proposal)).isFalse();
}
use of org.hyperledger.besu.consensus.common.bft.payload.SignedData in project besu by hyperledger.
the class ProposalValidatorTest method validationFailsIfPreparePayloadsDoNotMatchBlockHashInRoundChanges.
@Test
public void validationFailsIfPreparePayloadsDoNotMatchBlockHashInRoundChanges() {
final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE);
final List<SignedData<RoundChangePayload>> roundChanges = createPreparedRoundZeroRoundChanges();
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.common.bft.payload.SignedData 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();
}
Aggregations