|
|
|
@ -105,7 +105,7 @@ public class SignedDataValidatorTest { |
|
|
|
|
public void receivingAPrepareMessageBeforeProposalFails() { |
|
|
|
|
final Prepare prepareMsg = proposerMessageFactory.createPrepare(roundIdentifier, Hash.ZERO); |
|
|
|
|
|
|
|
|
|
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validatePrepare(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -114,7 +114,7 @@ public class SignedDataValidatorTest { |
|
|
|
|
proposerMessageFactory.createCommit( |
|
|
|
|
roundIdentifier, Hash.ZERO, SECP256K1.sign(block.getHash(), proposerKey)); |
|
|
|
|
|
|
|
|
|
assertThat(validator.validateCommmitMessage(commitMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateCommit(commitMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -122,7 +122,7 @@ public class SignedDataValidatorTest { |
|
|
|
|
final Proposal proposalMsg = |
|
|
|
|
validatorMessageFactory.createProposal(roundIdentifier, mock(Block.class)); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -131,7 +131,7 @@ public class SignedDataValidatorTest { |
|
|
|
|
final Proposal proposalMsg = |
|
|
|
|
proposerMessageFactory.createProposal(roundIdentifier, mock(Block.class)); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -141,8 +141,8 @@ public class SignedDataValidatorTest { |
|
|
|
|
final Prepare prepareMsg = |
|
|
|
|
proposerMessageFactory.createPrepare(roundIdentifier, block.getHash()); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepare(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -152,8 +152,8 @@ public class SignedDataValidatorTest { |
|
|
|
|
final Prepare prepareMsg = |
|
|
|
|
nonValidatorMessageFactory.createPrepare(roundIdentifier, block.getHash()); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepare(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -169,9 +169,9 @@ public class SignedDataValidatorTest { |
|
|
|
|
validatorMessageFactory.createCommit( |
|
|
|
|
invalidRoundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), proposerKey)); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateCommmitMessage(commitMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepare(prepareMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateCommit(commitMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -180,8 +180,8 @@ public class SignedDataValidatorTest { |
|
|
|
|
final Prepare prepareMsg = |
|
|
|
|
validatorMessageFactory.createPrepare(roundIdentifier, block.getHash()); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validatePrepare(prepareMsg.getSignedPayload())).isTrue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -192,8 +192,8 @@ public class SignedDataValidatorTest { |
|
|
|
|
proposerMessageFactory.createCommit( |
|
|
|
|
roundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), nonValidatorKey)); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateCommmitMessage(commitMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateCommit(commitMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -208,40 +208,40 @@ public class SignedDataValidatorTest { |
|
|
|
|
validatorMessageFactory.createCommit( |
|
|
|
|
roundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), validatorKey)); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateCommmitMessage(proposerCommitMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateCommmitMessage(validatorCommitMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateCommit(proposerCommitMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateCommit(validatorCommitMsg.getSignedPayload())).isTrue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void subsequentProposalHasDifferentSenderFails() { |
|
|
|
|
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block); |
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
|
|
|
|
|
final Proposal secondProposalMsg = |
|
|
|
|
validatorMessageFactory.createProposal(roundIdentifier, block); |
|
|
|
|
assertThat(validator.addSignedProposalPayload(secondProposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(secondProposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void subsequentProposalHasDifferentContentFails() { |
|
|
|
|
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block); |
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
|
|
|
|
|
final ConsensusRoundIdentifier newRoundIdentifier = new ConsensusRoundIdentifier(3, 0); |
|
|
|
|
final Proposal secondProposalMsg = |
|
|
|
|
proposerMessageFactory.createProposal(newRoundIdentifier, block); |
|
|
|
|
assertThat(validator.addSignedProposalPayload(secondProposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(secondProposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void subsequentProposalHasIdenticalSenderAndContentIsSuccessful() { |
|
|
|
|
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block); |
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
|
|
|
|
|
final Proposal secondProposalMsg = |
|
|
|
|
proposerMessageFactory.createProposal(roundIdentifier, block); |
|
|
|
|
assertThat(validator.addSignedProposalPayload(secondProposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
assertThat(validator.validateProposal(secondProposalMsg.getSignedPayload())).isTrue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -250,6 +250,6 @@ public class SignedDataValidatorTest { |
|
|
|
|
|
|
|
|
|
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block); |
|
|
|
|
|
|
|
|
|
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
assertThat(validator.validateProposal(proposalMsg.getSignedPayload())).isFalse(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|