Rename Ibft MessageFactory methods (#779)

Renamed MessageFactory method names from createSignedXPayload, to simply
createX.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
tmohay 6 years ago committed by GitHub
parent e3bdc13edb
commit 53510a14cf
  1. 14
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java
  2. 8
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestHelpers.java
  3. 11
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/ValidatorPeer.java
  4. 11
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/FutureHeightTest.java
  5. 6
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/FutureRoundTest.java
  6. 11
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java
  7. 3
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/LocalNodeIsProposerTest.java
  8. 3
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/LocalNodeNotProposerTest.java
  9. 19
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/ReceivedNewRoundTest.java
  10. 31
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/RoundChangeTest.java
  11. 4
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/SpuriousBehaviourTest.java
  12. 12
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/IbftMessageTransmitter.java
  13. 11
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/MessageFactory.java
  14. 2
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManager.java
  15. 11
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRound.java
  16. 22
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftHelpersTest.java
  17. 11
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/TestHelpers.java
  18. 18
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
  19. 38
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRoundTest.java
  20. 9
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java
  21. 44
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundStateTest.java
  22. 7
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/MessageValidatorTest.java
  23. 4
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundMessageValidatorTest.java
  24. 53
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundSignedDataValidatorTest.java
  25. 3
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/RoundChangeMessageValidatorTest.java
  26. 39
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/RoundChangeSignedDataValidatorTest.java
  27. 61
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/SignedDataValidatorTest.java

@ -104,11 +104,7 @@ public class RoundSpecificPeers {
final ConsensusRoundIdentifier roundId) {
return peers
.stream()
.map(
p ->
p.getMessageFactory()
.createSignedRoundChangePayload(roundId, empty())
.getSignedPayload())
.map(p -> p.getMessageFactory().createRoundChange(roundId, empty()).getSignedPayload())
.collect(Collectors.toList());
}
@ -120,7 +116,7 @@ public class RoundSpecificPeers {
.map(
p ->
p.getMessageFactory()
.createSignedRoundChangePayload(roundId, Optional.of(terminatedRoundArtefacts))
.createRoundChange(roundId, Optional.of(terminatedRoundArtefacts))
.getSignedPayload())
.collect(Collectors.toList());
}
@ -137,11 +133,7 @@ public class RoundSpecificPeers {
final ConsensusRoundIdentifier preparedRound, final Hash hash) {
return nonProposingPeers
.stream()
.map(
role ->
role.getMessageFactory()
.createSignedPreparePayload(preparedRound, hash)
.getSignedPayload())
.map(role -> role.getMessageFactory().createPrepare(preparedRound, hash).getSignedPayload())
.collect(Collectors.toList());
}

@ -46,9 +46,7 @@ public class TestHelpers {
final MessageFactory messageFactory = new MessageFactory(signingKeyPair);
return messageFactory
.createSignedCommitPayload(roundId, block.getHash(), commitSeal)
.getSignedPayload();
return messageFactory.createCommit(roundId, block.getHash(), commitSeal).getSignedPayload();
}
public static TerminatedRoundArtefacts createValidTerminatedRoundArtefacts(
@ -56,7 +54,7 @@ public class TestHelpers {
final RoundSpecificPeers peers = context.roundSpecificPeers(preparedRound);
return new TerminatedRoundArtefacts(
peers.getProposer().getMessageFactory().createSignedProposalPayload(preparedRound, block),
peers.getProposer().getMessageFactory().createProposal(preparedRound, block),
peers
.createSignedPreparePayloadOfNonProposing(preparedRound, block.getHash())
.stream()
@ -71,7 +69,7 @@ public class TestHelpers {
final Block blockToPropose) {
final Proposal proposal =
proposer.getMessageFactory().createSignedProposalPayload(targetRoundId, blockToPropose);
proposer.getMessageFactory().createProposal(targetRoundId, blockToPropose);
return proposer.injectNewRound(
targetRoundId,

@ -79,14 +79,14 @@ public class ValidatorPeer {
}
public Proposal injectProposal(final ConsensusRoundIdentifier rId, final Block block) {
final Proposal payload = messageFactory.createSignedProposalPayload(rId, block);
final Proposal payload = messageFactory.createProposal(rId, block);
injectMessage(ProposalMessageData.create(payload));
return payload;
}
public Prepare injectPrepare(final ConsensusRoundIdentifier rId, final Hash digest) {
final Prepare payload = messageFactory.createSignedPreparePayload(rId, digest);
final Prepare payload = messageFactory.createPrepare(rId, digest);
injectMessage(PrepareMessageData.create(payload));
return payload;
}
@ -103,7 +103,7 @@ public class ValidatorPeer {
public Commit injectCommit(
final ConsensusRoundIdentifier rId, final Hash digest, final Signature commitSeal) {
final Commit payload = messageFactory.createSignedCommitPayload(rId, digest, commitSeal);
final Commit payload = messageFactory.createCommit(rId, digest, commitSeal);
injectMessage(CommitMessageData.create(payload));
return payload;
}
@ -114,7 +114,7 @@ public class ValidatorPeer {
final SignedData<ProposalPayload> proposalPayload) {
final NewRound payload =
messageFactory.createSignedNewRoundPayload(rId, roundChangeCertificate, proposalPayload);
messageFactory.createNewRound(rId, roundChangeCertificate, proposalPayload);
injectMessage(NewRoundMessageData.create(payload));
return payload;
}
@ -122,8 +122,7 @@ public class ValidatorPeer {
public RoundChange injectRoundChange(
final ConsensusRoundIdentifier rId,
final Optional<TerminatedRoundArtefacts> terminatedRoundArtefacts) {
final RoundChange payload =
messageFactory.createSignedRoundChangePayload(rId, terminatedRoundArtefacts);
final RoundChange payload = messageFactory.createRoundChange(rId, terminatedRoundArtefacts);
injectMessage(RoundChangeMessageData.create(payload));
return payload;
}

@ -89,8 +89,7 @@ public class FutureHeightTest {
.handleNewBlockEvent(new NewChainHead(signedCurrentHeightBlock.getHeader()));
final Prepare expectedPrepareMessage =
localNodeMessageFactory.createSignedPreparePayload(
futureHeightRoundId, futureHeightBlock.getHash());
localNodeMessageFactory.createPrepare(futureHeightRoundId, futureHeightBlock.getHash());
final Commit expectedCommitMessage =
new Commit(
@ -113,7 +112,7 @@ public class FutureHeightTest {
peers.getNonProposing(0).injectPrepare(roundId, currentHeightBlock.getHash());
final Prepare expectedPrepareMessage =
localNodeMessageFactory.createSignedPreparePayload(roundId, currentHeightBlock.getHash());
localNodeMessageFactory.createPrepare(roundId, currentHeightBlock.getHash());
peers.verifyMessagesReceived(expectedPrepareMessage);
@ -189,8 +188,7 @@ public class FutureHeightTest {
peers.getProposer().injectProposal(nextHeightRoundId, nextHeightBlock);
final Prepare expectedPrepareMessage =
localNodeMessageFactory.createSignedPreparePayload(
nextHeightRoundId, nextHeightBlock.getHash());
localNodeMessageFactory.createPrepare(nextHeightRoundId, nextHeightBlock.getHash());
// Assert ONLY a prepare message was received, not any commits (i.e. futureHeightRoundId
// messages have not been used.
@ -206,8 +204,7 @@ public class FutureHeightTest {
.handleNewBlockEvent(new NewChainHead(signedNextHeightBlock.getHeader()));
final Prepare expectedFuturePrepareMessage =
localNodeMessageFactory.createSignedPreparePayload(
futureHeightRoundId, futureHeightBlock.getHash());
localNodeMessageFactory.createPrepare(futureHeightRoundId, futureHeightBlock.getHash());
final Commit expectedCommitMessage =
new Commit(

@ -99,7 +99,7 @@ public class FutureRoundTest {
futureBlock);
final Prepare expectedPrepare =
localNodeMessageFactory.createSignedPreparePayload(futureRoundId, futureBlock.getHash());
localNodeMessageFactory.createPrepare(futureRoundId, futureBlock.getHash());
peers.verifyMessagesReceived(expectedPrepare);
@ -107,7 +107,7 @@ public class FutureRoundTest {
futurePeers.getNonProposing(quorum - 3).injectPrepare(futureRoundId, futureBlock.getHash());
final Commit expectedCommit =
localNodeMessageFactory.createSignedCommitPayload(
localNodeMessageFactory.createCommit(
futureRoundId,
futureBlock.getHash(),
SECP256K1.sign(futureBlock.getHash(), context.getLocalNodeParams().getNodeKeyPair()));
@ -143,7 +143,7 @@ public class FutureRoundTest {
futureBlock);
final Prepare expectedFuturePrepare =
localNodeMessageFactory.createSignedPreparePayload(futureRoundId, futureBlock.getHash());
localNodeMessageFactory.createPrepare(futureRoundId, futureBlock.getHash());
peers.verifyMessagesReceived(expectedFuturePrepare);
// attempt to complete the previous round

@ -74,7 +74,7 @@ public class GossipTest {
@Test
public void gossipMessagesToPeers() {
final Prepare localPrepare =
context.getLocalNodeMessageFactory().createSignedPreparePayload(roundId, block.getHash());
context.getLocalNodeMessageFactory().createPrepare(roundId, block.getHash());
peers.verifyNoMessagesReceivedNonProposing();
final Proposal proposal = sender.injectProposal(roundId, block);
@ -90,8 +90,7 @@ public class GossipTest {
peers.verifyMessagesReceivedNonPropsing(commit);
peers.verifyNoMessagesReceivedProposer();
final RoundChange roundChange =
msgFactory.createSignedRoundChangePayload(roundId, Optional.empty());
final RoundChange roundChange = msgFactory.createRoundChange(roundId, Optional.empty());
final RoundChangeCertificate roundChangeCert =
new RoundChangeCertificate(singleton(roundChange.getSignedPayload()));
final NewRound newRound =
@ -120,7 +119,7 @@ public class GossipTest {
public void messageWithUnknownValidatorIsNotGossiped() {
final KeyPair unknownKeyPair = KeyPair.generate();
final MessageFactory unknownMsgFactory = new MessageFactory(unknownKeyPair);
final Proposal unknownProposal = unknownMsgFactory.createSignedProposalPayload(roundId, block);
final Proposal unknownProposal = unknownMsgFactory.createProposal(roundId, block);
sender.injectMessage(
ProposalMessageData.create(new Proposal(unknownProposal.getSignedPayload())));
@ -131,7 +130,7 @@ public class GossipTest {
public void messageIsNotGossipedToSenderOrCreator() {
final ValidatorPeer msgCreator = peers.getFirstNonProposer();
final MessageFactory peerMsgFactory = msgCreator.getMessageFactory();
final Proposal proposalFromPeer = peerMsgFactory.createSignedProposalPayload(roundId, block);
final Proposal proposalFromPeer = peerMsgFactory.createProposal(roundId, block);
sender.injectMessage(ProposalMessageData.create(proposalFromPeer));
@ -142,7 +141,7 @@ public class GossipTest {
@Test
public void futureMessageIsNotGossipedImmediately() {
ConsensusRoundIdentifier futureRoundId = new ConsensusRoundIdentifier(2, 0);
msgFactory.createSignedProposalPayload(futureRoundId, block);
msgFactory.createProposal(futureRoundId, block);
sender.injectProposal(futureRoundId, block);
peers.verifyNoMessagesReceived();

@ -63,8 +63,7 @@ public class LocalNodeIsProposerTest {
@Before
public void setup() {
expectedProposedBlock = context.createBlockForProposalFromChainHead(0, blockTimeStamp);
expectedTxProposal =
localNodeMessageFactory.createSignedProposalPayload(roundId, expectedProposedBlock);
expectedTxProposal = localNodeMessageFactory.createProposal(roundId, expectedProposedBlock);
expectedTxCommit =
new Commit(

@ -50,8 +50,7 @@ public class LocalNodeNotProposerTest {
@Before
public void setup() {
expectedTxPrepare =
localNodeMessageFactory.createSignedPreparePayload(roundId, blockToPropose.getHash());
expectedTxPrepare = localNodeMessageFactory.createPrepare(roundId, blockToPropose.getHash());
expectedTxCommit =
new Commit(

@ -73,11 +73,11 @@ public class ReceivedNewRoundTest {
new RoundChangeCertificate(roundChanges),
nextProposer
.getMessageFactory()
.createSignedProposalPayload(targetRound, blockToPropose)
.createProposal(targetRound, blockToPropose)
.getSignedPayload());
final Prepare expectedPrepare =
localNodeMessageFactory.createSignedPreparePayload(targetRound, blockToPropose.getHash());
localNodeMessageFactory.createPrepare(targetRound, blockToPropose.getHash());
peers.verifyMessagesReceived(expectedPrepare);
}
@ -99,7 +99,7 @@ public class ReceivedNewRoundTest {
new RoundChangeCertificate(roundChanges),
illegalProposer
.getMessageFactory()
.createSignedProposalPayload(nextRoundId, blockToPropose)
.createProposal(nextRoundId, blockToPropose)
.getSignedPayload());
peers.verifyNoMessagesReceived();
@ -125,11 +125,11 @@ public class ReceivedNewRoundTest {
peers
.getNonProposing(0)
.getMessageFactory()
.createSignedProposalPayload(nextRoundId, reproposedBlock)
.createProposal(nextRoundId, reproposedBlock)
.getSignedPayload());
peers.verifyMessagesReceived(
localNodeMessageFactory.createSignedPreparePayload(nextRoundId, reproposedBlock.getHash()));
localNodeMessageFactory.createPrepare(nextRoundId, reproposedBlock.getHash()));
}
@Test
@ -149,8 +149,7 @@ public class ReceivedNewRoundTest {
final Proposal proposal =
interimRoundProposer
.getMessageFactory()
.createSignedProposalPayload(
interimRound, context.createBlockForProposalFromChainHead(1, 30));
.createProposal(interimRound, context.createBlockForProposalFromChainHead(1, 30));
interimRoundProposer.injectNewRound(
interimRound, new RoundChangeCertificate(roundChangePayloads), proposal.getSignedPayload());
@ -179,11 +178,11 @@ public class ReceivedNewRoundTest {
peers
.getNonProposing(0)
.getMessageFactory()
.createSignedProposalPayload(nextRoundId, reproposedBlock)
.createProposal(nextRoundId, reproposedBlock)
.getSignedPayload());
peers.verifyMessagesReceived(
localNodeMessageFactory.createSignedPreparePayload(nextRoundId, reproposedBlock.getHash()));
localNodeMessageFactory.createPrepare(nextRoundId, reproposedBlock.getHash()));
// Inject a prepare, then re-inject the newRound - then ensure only a single prepare is enough
// to trigger a Commit transmission from the local node
@ -195,7 +194,7 @@ public class ReceivedNewRoundTest {
peers
.getNonProposing(0)
.getMessageFactory()
.createSignedProposalPayload(nextRoundId, reproposedBlock)
.createProposal(nextRoundId, reproposedBlock)
.getSignedPayload());
peers.verifyNoMessagesReceived();

@ -77,7 +77,7 @@ public class RoundChangeTest {
// NOTE: The prepare certificate will be empty as insufficient Prepare msgs have been received.
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
final RoundChange expectedTxRoundChange =
localNodeMessageFactory.createSignedRoundChangePayload(targetRound, empty());
localNodeMessageFactory.createRoundChange(targetRound, empty());
context.getController().handleRoundExpiry(new RoundExpiry(roundId));
peers.verifyMessagesReceived(expectedTxRoundChange);
}
@ -86,7 +86,7 @@ public class RoundChangeTest {
public void roundChangeHasEmptyCertificateIfNoPrepareMessagesReceived() {
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
final RoundChange expectedTxRoundChange =
localNodeMessageFactory.createSignedRoundChangePayload(targetRound, empty());
localNodeMessageFactory.createRoundChange(targetRound, empty());
peers.getProposer().injectProposal(roundId, blockToPropose);
peers.clearReceivedMessages();
@ -101,7 +101,7 @@ public class RoundChangeTest {
// receiving only a single Prepare msg will result in no PreparedCert.
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
final RoundChange expectedTxRoundChange =
localNodeMessageFactory.createSignedRoundChangePayload(targetRound, empty());
localNodeMessageFactory.createRoundChange(targetRound, empty());
peers.getProposer().injectProposal(roundId, blockToPropose);
peers.getNonProposing(1).injectPrepare(roundId, blockToPropose.getHash());
@ -115,7 +115,7 @@ public class RoundChangeTest {
public void roundChangeHasPopulatedCertificateIfQuorumPrepareMessagesAndProposalAreReceived() {
final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 1);
final Prepare localPrepareMessage =
localNodeMessageFactory.createSignedPreparePayload(roundId, blockToPropose.getHash());
localNodeMessageFactory.createPrepare(roundId, blockToPropose.getHash());
final Proposal proposal = peers.getProposer().injectProposal(roundId, blockToPropose);
peers.clearReceivedMessages();
@ -127,7 +127,7 @@ public class RoundChangeTest {
peers.clearReceivedMessages();
final RoundChange expectedTxRoundChange =
localNodeMessageFactory.createSignedRoundChangePayload(
localNodeMessageFactory.createRoundChange(
targetRound,
Optional.of(
new TerminatedRoundArtefacts(
@ -150,7 +150,7 @@ public class RoundChangeTest {
final RoundChange rc4 = peers.getProposer().injectRoundChange(targetRound, empty());
final NewRound expectedNewRound =
localNodeMessageFactory.createSignedNewRoundPayload(
localNodeMessageFactory.createNewRound(
targetRound,
new RoundChangeCertificate(
Lists.newArrayList(
@ -159,7 +159,7 @@ public class RoundChangeTest {
rc3.getSignedPayload(),
rc4.getSignedPayload())),
localNodeMessageFactory
.createSignedProposalPayload(targetRound, locallyProposedBlock)
.createProposal(targetRound, locallyProposedBlock)
.getSignedPayload());
peers.verifyMessagesReceived(expectedNewRound);
@ -204,7 +204,7 @@ public class RoundChangeTest {
targetRound.getRoundNumber(), ARBITRARY_BLOCKTIME);
final NewRound expectedNewRound =
localNodeMessageFactory.createSignedNewRoundPayload(
localNodeMessageFactory.createNewRound(
targetRound,
new RoundChangeCertificate(
Lists.newArrayList(
@ -213,7 +213,7 @@ public class RoundChangeTest {
rc3.getSignedPayload(),
rc4.getSignedPayload())),
localNodeMessageFactory
.createSignedProposalPayload(targetRound, expectedBlockToPropose)
.createProposal(targetRound, expectedBlockToPropose)
.getSignedPayload());
peers.verifyMessagesReceived(expectedNewRound);
@ -233,11 +233,11 @@ public class RoundChangeTest {
context.createBlockForProposalFromChainHead(futureRound.getRoundNumber(), blockTimeStamp);
final NewRound expectedNewRound =
localNodeMessageFactory.createSignedNewRoundPayload(
localNodeMessageFactory.createNewRound(
futureRound,
new RoundChangeCertificate(roundChangeMessages),
localNodeMessageFactory
.createSignedProposalPayload(futureRound, locallyProposedBlock)
.createProposal(futureRound, locallyProposedBlock)
.getSignedPayload());
peers.verifyMessagesReceived(expectedNewRound);
@ -287,11 +287,11 @@ public class RoundChangeTest {
targetRound.getRoundNumber(), ARBITRARY_BLOCKTIME);
final NewRound expectedNewRound =
localNodeMessageFactory.createSignedNewRoundPayload(
localNodeMessageFactory.createNewRound(
targetRound,
new RoundChangeCertificate(Lists.newArrayList(roundChangeMessages)),
localNodeMessageFactory
.createSignedProposalPayload(targetRound, expectedBlockToPropose)
.createProposal(targetRound, expectedBlockToPropose)
.getSignedPayload());
peers.verifyMessagesReceived(expectedNewRound);
@ -331,10 +331,7 @@ public class RoundChangeTest {
// create illegal RoundChangeMessage
final TerminatedRoundArtefacts illegalTerminatedRoundArtefacts =
new TerminatedRoundArtefacts(
peers
.getNonProposing(0)
.getMessageFactory()
.createSignedProposalPayload(roundId, blockToPropose),
peers.getNonProposing(0).getMessageFactory().createProposal(roundId, blockToPropose),
emptyList());
peers

@ -70,9 +70,7 @@ public class SpuriousBehaviourTest {
context.getController().start();
expectedPrepare =
context
.getLocalNodeMessageFactory()
.createSignedPreparePayload(roundId, proposedBlock.getHash());
context.getLocalNodeMessageFactory().createPrepare(roundId, proposedBlock.getHash());
expectedCommit =
new Commit(
createSignedCommitPayload(

@ -46,7 +46,7 @@ public class IbftMessageTransmitter {
}
public void multicastProposal(final ConsensusRoundIdentifier roundIdentifier, final Block block) {
final Proposal data = messageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal data = messageFactory.createProposal(roundIdentifier, block);
final ProposalMessageData message = ProposalMessageData.create(data);
@ -54,7 +54,7 @@ public class IbftMessageTransmitter {
}
public void multicastPrepare(final ConsensusRoundIdentifier roundIdentifier, final Hash digest) {
final Prepare data = messageFactory.createSignedPreparePayload(roundIdentifier, digest);
final Prepare data = messageFactory.createPrepare(roundIdentifier, digest);
final PrepareMessageData message = PrepareMessageData.create(data);
@ -65,8 +65,7 @@ public class IbftMessageTransmitter {
final ConsensusRoundIdentifier roundIdentifier,
final Hash digest,
final Signature commitSeal) {
final Commit data =
messageFactory.createSignedCommitPayload(roundIdentifier, digest, commitSeal);
final Commit data = messageFactory.createCommit(roundIdentifier, digest, commitSeal);
final CommitMessageData message = CommitMessageData.create(data);
@ -78,7 +77,7 @@ public class IbftMessageTransmitter {
final Optional<TerminatedRoundArtefacts> terminatedRoundArtefacts) {
final RoundChange data =
messageFactory.createSignedRoundChangePayload(roundIdentifier, terminatedRoundArtefacts);
messageFactory.createRoundChange(roundIdentifier, terminatedRoundArtefacts);
final RoundChangeMessageData message = RoundChangeMessageData.create(data);
@ -91,8 +90,7 @@ public class IbftMessageTransmitter {
final SignedData<ProposalPayload> proposalPayload) {
final NewRound signedPayload =
messageFactory.createSignedNewRoundPayload(
roundIdentifier, roundChangeCertificate, proposalPayload);
messageFactory.createNewRound(roundIdentifier, roundChangeCertificate, proposalPayload);
final NewRoundMessageData message = NewRoundMessageData.create(signedPayload);

@ -37,7 +37,7 @@ public class MessageFactory {
this.validatorKeyPair = validatorKeyPair;
}
public Proposal createSignedProposalPayload(
public Proposal createProposal(
final ConsensusRoundIdentifier roundIdentifier, final Block block) {
final ProposalPayload payload = new ProposalPayload(roundIdentifier, block);
@ -45,15 +45,14 @@ public class MessageFactory {
return new Proposal(createSignedMessage(payload));
}
public Prepare createSignedPreparePayload(
final ConsensusRoundIdentifier roundIdentifier, final Hash digest) {
public Prepare createPrepare(final ConsensusRoundIdentifier roundIdentifier, final Hash digest) {
final PreparePayload payload = new PreparePayload(roundIdentifier, digest);
return new Prepare(createSignedMessage(payload));
}
public Commit createSignedCommitPayload(
public Commit createCommit(
final ConsensusRoundIdentifier roundIdentifier,
final Hash digest,
final Signature commitSeal) {
@ -63,7 +62,7 @@ public class MessageFactory {
return new Commit(createSignedMessage(payload));
}
public RoundChange createSignedRoundChangePayload(
public RoundChange createRoundChange(
final ConsensusRoundIdentifier roundIdentifier,
final Optional<TerminatedRoundArtefacts> terminatedRoundArtefacts) {
@ -75,7 +74,7 @@ public class MessageFactory {
return new RoundChange(createSignedMessage(payload));
}
public NewRound createSignedNewRoundPayload(
public NewRound createNewRound(
final ConsensusRoundIdentifier roundIdentifier,
final RoundChangeCertificate roundChangeCertificate,
final SignedData<ProposalPayload> proposalPayload) {

@ -143,7 +143,7 @@ public class IbftBlockHeightManager implements BlockHeightManager {
startNewRound(currentRound.getRoundIdentifier().getRoundNumber() + 1);
final RoundChange localRoundChange =
messageFactory.createSignedRoundChangePayload(
messageFactory.createRoundChange(
currentRound.getRoundIdentifier(), latesteTerminatedRoundArtefacts);
transmitter.multicastRoundChange(
currentRound.getRoundIdentifier(), latesteTerminatedRoundArtefacts);

@ -89,7 +89,7 @@ public class IbftRound {
transmitter.multicastProposal(roundState.getRoundIdentifier(), block);
updateStateWithProposedBlock(
messageFactory.createSignedProposalPayload(roundState.getRoundIdentifier(), block));
messageFactory.createProposal(roundState.getRoundIdentifier(), block));
}
public void startRoundWith(
@ -100,7 +100,7 @@ public class IbftRound {
if (!bestBlockFromRoundChange.isPresent()) {
LOG.trace("Multicasting NewRound with new block. round={}", roundState.getRoundIdentifier());
final Block block = blockCreator.createBlock(headerTimestamp);
proposal = messageFactory.createSignedProposalPayload(getRoundIdentifier(), block);
proposal = messageFactory.createProposal(getRoundIdentifier(), block);
} else {
LOG.trace(
"Multicasting NewRound from PreparedCertificate. round={}",
@ -120,7 +120,7 @@ public class IbftRound {
block,
getRoundIdentifier().getRoundNumber(),
IbftBlockHashing::calculateDataHashForCommittedSeal);
return messageFactory.createSignedProposalPayload(getRoundIdentifier(), blockToPublish);
return messageFactory.createProposal(getRoundIdentifier(), blockToPublish);
}
public void handleProposalMessage(final Proposal msg) {
@ -150,8 +150,7 @@ public class IbftRound {
LOG.info("Sending prepare message.");
transmitter.multicastPrepare(getRoundIdentifier(), block.getHash());
final Prepare localPrepareMessage =
messageFactory.createSignedPreparePayload(
roundState.getRoundIdentifier(), block.getHash());
messageFactory.createPrepare(roundState.getRoundIdentifier(), block.getHash());
peerIsPrepared(localPrepareMessage);
}
}
@ -186,7 +185,7 @@ public class IbftRound {
}
final Commit localCommitMessage =
messageFactory.createSignedCommitPayload(
messageFactory.createCommit(
roundState.getRoundIdentifier(),
msg.getBlock().getHash(),
createCommitSeal(roundState.getProposedBlock().get()));

@ -91,16 +91,15 @@ public class IbftHelpersTest {
final ConsensusRoundIdentifier preparedRound = TestHelpers.createFrom(roundIdentifier, 0, -1);
final Proposal differentProposal =
proposerMessageFactory.createSignedProposalPayload(preparedRound, proposedBlock);
proposerMessageFactory.createProposal(preparedRound, proposedBlock);
final Optional<TerminatedRoundArtefacts> latterTerminatedRoundArtefacts =
Optional.of(
new TerminatedRoundArtefacts(
differentProposal,
Lists.newArrayList(
proposerMessageFactory.createSignedPreparePayload(
roundIdentifier, proposedBlock.getHash()),
proposerMessageFactory.createSignedPreparePayload(
proposerMessageFactory.createPrepare(roundIdentifier, proposedBlock.getHash()),
proposerMessageFactory.createPrepare(
roundIdentifier, proposedBlock.getHash()))));
// An earlier PrepareCert is added to ensure the path to find the latest PrepareCert
@ -108,26 +107,25 @@ public class IbftHelpersTest {
final ConsensusRoundIdentifier earlierPreparedRound =
TestHelpers.createFrom(roundIdentifier, 0, -2);
final Proposal earlierProposal =
proposerMessageFactory.createSignedProposalPayload(earlierPreparedRound, proposedBlock);
proposerMessageFactory.createProposal(earlierPreparedRound, proposedBlock);
final Optional<TerminatedRoundArtefacts> earlierTerminatedRoundArtefacts =
Optional.of(
new TerminatedRoundArtefacts(
earlierProposal,
Lists.newArrayList(
proposerMessageFactory.createSignedPreparePayload(
proposerMessageFactory.createPrepare(
earlierPreparedRound, proposedBlock.getHash()),
proposerMessageFactory.createSignedPreparePayload(
proposerMessageFactory.createPrepare(
earlierPreparedRound, proposedBlock.getHash()))));
final Optional<PreparedCertificate> newestCert =
IbftHelpers.findLatestPreparedCertificate(
Lists.newArrayList(
proposerMessageFactory
.createSignedRoundChangePayload(
roundIdentifier, earlierTerminatedRoundArtefacts)
.createRoundChange(roundIdentifier, earlierTerminatedRoundArtefacts)
.getSignedPayload(),
proposerMessageFactory
.createSignedRoundChangePayload(roundIdentifier, latterTerminatedRoundArtefacts)
.createRoundChange(roundIdentifier, latterTerminatedRoundArtefacts)
.getSignedPayload()));
assertThat(newestCert.get())
@ -144,10 +142,10 @@ public class IbftHelpersTest {
IbftHelpers.findLatestPreparedCertificate(
Lists.newArrayList(
proposerMessageFactory
.createSignedRoundChangePayload(roundIdentifier, Optional.empty())
.createRoundChange(roundIdentifier, Optional.empty())
.getSignedPayload(),
proposerMessageFactory
.createSignedRoundChangePayload(roundIdentifier, Optional.empty())
.createRoundChange(roundIdentifier, Optional.empty())
.getSignedPayload()));
assertThat(newestCert).isEmpty();

@ -72,22 +72,21 @@ public class TestHelpers {
new ConsensusRoundIdentifier(0x1234567890ABCDEFL, round);
final Block block =
TestHelpers.createProposalBlock(singletonList(AddressHelpers.ofValue(1)), 0);
return messageFactory.createSignedProposalPayload(roundIdentifier, block);
return messageFactory.createProposal(roundIdentifier, block);
}
public static Prepare createSignedPreparePayload(final KeyPair signerKeys) {
final MessageFactory messageFactory = new MessageFactory(signerKeys);
final ConsensusRoundIdentifier roundIdentifier =
new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98);
return messageFactory.createSignedPreparePayload(
roundIdentifier, Hash.fromHexStringLenient("0"));
return messageFactory.createPrepare(roundIdentifier, Hash.fromHexStringLenient("0"));
}
public static Commit createSignedCommitPayload(final KeyPair signerKeys) {
final MessageFactory messageFactory = new MessageFactory(signerKeys);
final ConsensusRoundIdentifier roundIdentifier =
new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98);
return messageFactory.createSignedCommitPayload(
return messageFactory.createCommit(
roundIdentifier,
Hash.fromHexStringLenient("0"),
Signature.create(BigInteger.ONE, BigInteger.TEN, (byte) 0));
@ -97,7 +96,7 @@ public class TestHelpers {
final MessageFactory messageFactory = new MessageFactory(signerKeys);
final ConsensusRoundIdentifier roundIdentifier =
new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98);
return messageFactory.createSignedRoundChangePayload(roundIdentifier, Optional.empty());
return messageFactory.createRoundChange(roundIdentifier, Optional.empty());
}
public static NewRound createSignedNewRoundPayload(final KeyPair signerKeys) {
@ -105,7 +104,7 @@ public class TestHelpers {
final ConsensusRoundIdentifier roundIdentifier =
new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98);
final Proposal proposalPayload = createSignedProposalPayload(signerKeys);
return messageFactory.createSignedNewRoundPayload(
return messageFactory.createNewRound(
roundIdentifier,
new RoundChangeCertificate(newArrayList()),
proposalPayload.getSignedPayload());

@ -216,7 +216,7 @@ public class IbftBlockHeightManagerTest {
public void onRoundChangeReceptionRoundChangeManagerIsInvokedAndNewRoundStarted() {
final ConsensusRoundIdentifier futureRoundIdentifier = createFrom(roundIdentifier, 0, +2);
final RoundChange roundChange =
messageFactory.createSignedRoundChangePayload(futureRoundIdentifier, Optional.empty());
messageFactory.createRoundChange(futureRoundIdentifier, Optional.empty());
when(roundChangeManager.appendRoundChangeMessage(any()))
.thenReturn(Optional.of(singletonList(roundChange)));
when(finalState.isLocalNodeProposerForRound(any())).thenReturn(false);
@ -260,7 +260,7 @@ public class IbftBlockHeightManagerTest {
public void whenSufficientRoundChangesAreReceivedANewRoundMessageIsTransmitted() {
final ConsensusRoundIdentifier futureRoundIdentifier = createFrom(roundIdentifier, 0, +2);
final RoundChange roundChange =
messageFactory.createSignedRoundChangePayload(futureRoundIdentifier, Optional.empty());
messageFactory.createRoundChange(futureRoundIdentifier, Optional.empty());
final RoundChangeCertificate roundChangCert =
new RoundChangeCertificate(singletonList(roundChange.getSignedPayload()));
@ -301,11 +301,11 @@ public class IbftBlockHeightManagerTest {
final Prepare prepare =
validatorMessageFactory
.get(0)
.createSignedPreparePayload(futureRoundIdentifier, Hash.fromHexStringLenient("0"));
.createPrepare(futureRoundIdentifier, Hash.fromHexStringLenient("0"));
final Commit commit =
validatorMessageFactory
.get(1)
.createSignedCommitPayload(
.createCommit(
futureRoundIdentifier,
Hash.fromHexStringLenient("0"),
Signature.create(BigInteger.ONE, BigInteger.ONE, (byte) 1));
@ -315,12 +315,10 @@ public class IbftBlockHeightManagerTest {
// Force a new round to be started at new round number.
final NewRound newRound =
messageFactory.createSignedNewRoundPayload(
messageFactory.createNewRound(
futureRoundIdentifier,
new RoundChangeCertificate(Collections.emptyList()),
messageFactory
.createSignedProposalPayload(futureRoundIdentifier, createdBlock)
.getSignedPayload());
messageFactory.createProposal(futureRoundIdentifier, createdBlock).getSignedPayload());
manager.handleNewRoundPayload(newRound);
@ -345,11 +343,11 @@ public class IbftBlockHeightManagerTest {
final Prepare firstPrepare =
validatorMessageFactory
.get(0)
.createSignedPreparePayload(roundIdentifier, Hash.fromHexStringLenient("0"));
.createPrepare(roundIdentifier, Hash.fromHexStringLenient("0"));
final Prepare secondPrepare =
validatorMessageFactory
.get(1)
.createSignedPreparePayload(roundIdentifier, Hash.fromHexStringLenient("0"));
.createPrepare(roundIdentifier, Hash.fromHexStringLenient("0"));
manager.handlePreparePayload(firstPrepare);
manager.handlePreparePayload(secondPrepare);

@ -131,8 +131,7 @@ public class IbftRoundTest {
messageFactory,
transmitter);
round.handleProposalMessage(
messageFactory.createSignedProposalPayload(roundIdentifier, proposedBlock));
round.handleProposalMessage(messageFactory.createProposal(roundIdentifier, proposedBlock));
verify(transmitter, times(1)).multicastPrepare(roundIdentifier, proposedBlock.getHash());
verify(transmitter, never()).multicastCommit(any(), any(), any());
}
@ -197,8 +196,7 @@ public class IbftRoundTest {
final Signature localCommitSeal = SECP256K1.sign(commitSealHash, localNodeKeys);
// Receive Proposal Message
round.handleProposalMessage(
messageFactory.createSignedProposalPayload(roundIdentifier, proposedBlock));
round.handleProposalMessage(messageFactory.createProposal(roundIdentifier, proposedBlock));
verify(transmitter, times(1)).multicastPrepare(roundIdentifier, proposedBlock.getHash());
verify(transmitter, times(1))
.multicastCommit(roundIdentifier, proposedBlock.getHash(), localCommitSeal);
@ -207,8 +205,7 @@ public class IbftRoundTest {
// Receive Commit Message
round.handleCommitMessage(
messageFactory.createSignedCommitPayload(
roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
messageFactory.createCommit(roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
// Should import block when both commit seals are available.
ArgumentCaptor<Block> capturedBlock = ArgumentCaptor.forClass(Block.class);
@ -244,15 +241,14 @@ public class IbftRoundTest {
verify(blockImporter, never()).importBlock(any(), any(), any());
round.handlePrepareMessage(
messageFactory.createSignedPreparePayload(roundIdentifier, proposedBlock.getHash()));
messageFactory.createPrepare(roundIdentifier, proposedBlock.getHash()));
verify(transmitter, times(1))
.multicastCommit(roundIdentifier, proposedBlock.getHash(), localCommitSeal);
verify(blockImporter, never()).importBlock(any(), any(), any());
round.handleCommitMessage(
messageFactory.createSignedCommitPayload(
roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
messageFactory.createCommit(roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
verify(blockImporter, times(1)).importBlock(any(), any(), any());
}
@ -295,12 +291,11 @@ public class IbftRoundTest {
final RoundChangeArtefacts roundChangeArtefacts =
RoundChangeArtefacts.create(
Collections.singletonList(
messageFactory.createSignedRoundChangePayload(
messageFactory.createRoundChange(
roundIdentifier,
Optional.of(
new TerminatedRoundArtefacts(
messageFactory.createSignedProposalPayload(
priorRoundChange, proposedBlock),
messageFactory.createProposal(priorRoundChange, proposedBlock),
emptyList())))));
// NOTE: IbftRound assumes the prepare's are valid
@ -320,7 +315,7 @@ public class IbftRoundTest {
// Inject a single Prepare message, and confirm the roundState has gone to Prepared (which
// indicates the block has entered the roundState (note: all msgs are deemed valid due to mocks)
round.handlePrepareMessage(
messageFactory.createSignedPreparePayload(roundIdentifier, proposedBlock.getHash()));
messageFactory.createPrepare(roundIdentifier, proposedBlock.getHash()));
assertThat(roundState.isPrepared()).isTrue();
}
@ -340,8 +335,7 @@ public class IbftRoundTest {
final RoundChangeArtefacts roundChangeArtefacts =
RoundChangeArtefacts.create(
Collections.singletonList(
messageFactory.createSignedRoundChangePayload(roundIdentifier, empty())));
Collections.singletonList(messageFactory.createRoundChange(roundIdentifier, empty())));
round.startRoundWith(roundChangeArtefacts, 15);
verify(transmitter, times(1))
@ -353,7 +347,7 @@ public class IbftRoundTest {
// Inject a single Prepare message, and confirm the roundState has gone to Prepared (which
// indicates the block has entered the roundState (note: all msgs are deemed valid due to mocks)
round.handlePrepareMessage(
messageFactory.createSignedPreparePayload(roundIdentifier, proposedBlock.getHash()));
messageFactory.createPrepare(roundIdentifier, proposedBlock.getHash()));
assertThat(roundState.isPrepared()).isTrue();
}
@ -391,11 +385,9 @@ public class IbftRoundTest {
transmitter);
round.handleCommitMessage(
messageFactory.createSignedCommitPayload(
roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
messageFactory.createCommit(roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
round.handleProposalMessage(
messageFactory.createSignedProposalPayload(roundIdentifier, proposedBlock));
round.handleProposalMessage(messageFactory.createProposal(roundIdentifier, proposedBlock));
verify(blockImporter, times(1)).importBlock(any(), any(), any());
}
@ -416,11 +408,9 @@ public class IbftRoundTest {
transmitter);
round.handleCommitMessage(
messageFactory.createSignedCommitPayload(
roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
messageFactory.createCommit(roundIdentifier, proposedBlock.getHash(), remoteCommitSeal));
round.handleProposalMessage(
messageFactory.createSignedProposalPayload(roundIdentifier, proposedBlock));
round.handleProposalMessage(messageFactory.createProposal(roundIdentifier, proposedBlock));
verify(blockImporter, times(1)).importBlock(any(), any(), any());
}

@ -126,7 +126,7 @@ public class RoundChangeManagerTest {
private RoundChange makeRoundChangeMessage(
final KeyPair key, final ConsensusRoundIdentifier round) {
MessageFactory messageFactory = new MessageFactory(key);
return messageFactory.createSignedRoundChangePayload(round, Optional.empty());
return messageFactory.createRoundChange(round, Optional.empty());
}
private RoundChange makeRoundChangeMessageWithPreparedCert(
@ -140,7 +140,7 @@ public class RoundChangeManagerTest {
final ConsensusRoundIdentifier proposalRound = TestHelpers.createFrom(round, 0, -1);
final Block block = TestHelpers.createProposalBlock(validators, proposalRound.getRoundNumber());
// Proposal must come from an earlier round.
final Proposal proposal = messageFactory.createSignedProposalPayload(proposalRound, block);
final Proposal proposal = messageFactory.createProposal(proposalRound, block);
final List<Prepare> preparePayloads =
prepareProviders
@ -148,15 +148,14 @@ public class RoundChangeManagerTest {
.map(
k -> {
final MessageFactory prepareFactory = new MessageFactory(k);
return prepareFactory.createSignedPreparePayload(proposalRound, block.getHash());
return prepareFactory.createPrepare(proposalRound, block.getHash());
})
.collect(Collectors.toList());
final TerminatedRoundArtefacts terminatedRoundArtects =
new TerminatedRoundArtefacts(proposal, preparePayloads);
return messageFactory.createSignedRoundChangePayload(
round, Optional.of(terminatedRoundArtects));
return messageFactory.createRoundChange(round, Optional.of(terminatedRoundArtects));
}
@Test

@ -80,7 +80,7 @@ public class RoundStateTest {
final RoundState roundState = new RoundState(roundIdentifier, 1, messageValidator);
final Proposal proposal =
validatorMessageFactories.get(0).createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactories.get(0).createProposal(roundIdentifier, block);
assertThat(roundState.setProposedBlock(proposal)).isFalse();
assertThat(roundState.isPrepared()).isFalse();
@ -94,7 +94,7 @@ public class RoundStateTest {
final RoundState roundState = new RoundState(roundIdentifier, 1, messageValidator);
final Proposal proposal =
validatorMessageFactories.get(0).createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactories.get(0).createProposal(roundIdentifier, block);
assertThat(roundState.setProposedBlock(proposal)).isTrue();
assertThat(roundState.isPrepared()).isTrue();
@ -117,7 +117,7 @@ public class RoundStateTest {
final RoundState roundState = new RoundState(roundIdentifier, 1, messageValidator);
final Proposal proposal =
validatorMessageFactories.get(0).createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactories.get(0).createProposal(roundIdentifier, block);
assertThat(roundState.setProposedBlock(proposal)).isTrue();
assertThat(roundState.isPrepared()).isTrue();
@ -126,7 +126,7 @@ public class RoundStateTest {
final Commit commit =
validatorMessageFactories
.get(0)
.createSignedCommitPayload(
.createCommit(
roundIdentifier,
block.getHash(),
Signature.create(BigInteger.ONE, BigInteger.ONE, (byte) 1));
@ -145,14 +145,10 @@ public class RoundStateTest {
final RoundState roundState = new RoundState(roundIdentifier, 3, messageValidator);
final Prepare firstPrepare =
validatorMessageFactories
.get(1)
.createSignedPreparePayload(roundIdentifier, block.getHash());
validatorMessageFactories.get(1).createPrepare(roundIdentifier, block.getHash());
final Prepare secondPrepare =
validatorMessageFactories
.get(2)
.createSignedPreparePayload(roundIdentifier, block.getHash());
validatorMessageFactories.get(2).createPrepare(roundIdentifier, block.getHash());
roundState.addPrepareMessage(firstPrepare);
assertThat(roundState.isPrepared()).isFalse();
@ -165,7 +161,7 @@ public class RoundStateTest {
assertThat(roundState.constructTerminatedRoundArtefacts()).isEmpty();
final Proposal proposal =
validatorMessageFactories.get(0).createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactories.get(0).createProposal(roundIdentifier, block);
assertThat(roundState.setProposedBlock(proposal)).isTrue();
assertThat(roundState.isPrepared()).isTrue();
assertThat(roundState.isCommitted()).isFalse();
@ -175,14 +171,10 @@ public class RoundStateTest {
@Test
public void invalidPriorPrepareMessagesAreDiscardedUponSubsequentProposal() {
final Prepare firstPrepare =
validatorMessageFactories
.get(1)
.createSignedPreparePayload(roundIdentifier, block.getHash());
validatorMessageFactories.get(1).createPrepare(roundIdentifier, block.getHash());
final Prepare secondPrepare =
validatorMessageFactories
.get(2)
.createSignedPreparePayload(roundIdentifier, block.getHash());
validatorMessageFactories.get(2).createPrepare(roundIdentifier, block.getHash());
// RoundState has a quorum size of 3, meaning 1 proposal and 2 prepare are required to be
// 'prepared'.
@ -197,7 +189,7 @@ public class RoundStateTest {
verify(messageValidator, never()).validatePrepareMessage(any());
final Proposal proposal =
validatorMessageFactories.get(0).createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactories.get(0).createProposal(roundIdentifier, block);
assertThat(roundState.setProposedBlock(proposal)).isTrue();
assertThat(roundState.isPrepared()).isFalse();
@ -210,17 +202,13 @@ public class RoundStateTest {
final RoundState roundState = new RoundState(roundIdentifier, 2, messageValidator);
final Prepare firstPrepare =
validatorMessageFactories
.get(1)
.createSignedPreparePayload(roundIdentifier, block.getHash());
validatorMessageFactories.get(1).createPrepare(roundIdentifier, block.getHash());
final Prepare secondPrepare =
validatorMessageFactories
.get(2)
.createSignedPreparePayload(roundIdentifier, block.getHash());
validatorMessageFactories.get(2).createPrepare(roundIdentifier, block.getHash());
final Proposal proposal =
validatorMessageFactories.get(0).createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactories.get(0).createProposal(roundIdentifier, block);
when(messageValidator.addSignedProposalPayload(any())).thenReturn(true);
when(messageValidator.validatePrepareMessage(firstPrepare)).thenReturn(false);
@ -246,7 +234,7 @@ public class RoundStateTest {
final Commit firstCommit =
validatorMessageFactories
.get(1)
.createSignedCommitPayload(
.createCommit(
roundIdentifier,
block.getHash(),
Signature.create(BigInteger.ONE, BigInteger.TEN, (byte) 1));
@ -254,13 +242,13 @@ public class RoundStateTest {
final Commit secondCommit =
validatorMessageFactories
.get(2)
.createSignedCommitPayload(
.createCommit(
roundIdentifier,
block.getHash(),
Signature.create(BigInteger.TEN, BigInteger.TEN, (byte) 1));
final Proposal proposal =
validatorMessageFactories.get(0).createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactories.get(0).createProposal(roundIdentifier, block);
roundState.setProposedBlock(proposal);
roundState.addCommitMessage(firstCommit);

@ -65,13 +65,12 @@ public class MessageValidatorTest {
@Test
public void messageValidatorDefersToUnderlyingSignedDataValidator() {
final Proposal proposal = messageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposal = messageFactory.createProposal(roundIdentifier, block);
final Prepare prepare =
messageFactory.createSignedPreparePayload(roundIdentifier, block.getHash());
final Prepare prepare = messageFactory.createPrepare(roundIdentifier, block.getHash());
final Commit commit =
messageFactory.createSignedCommitPayload(
messageFactory.createCommit(
roundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), keyPair));
messageValidator.addSignedProposalPayload(proposal);

@ -41,10 +41,10 @@ public class NewRoundMessageValidatorTest {
@Test
public void underlyingPayloadValidatorIsInvokedWithCorrectParameters() {
final NewRound message =
messageFactory.createSignedNewRoundPayload(
messageFactory.createNewRound(
roundIdentifier,
new RoundChangeCertificate(emptyList()),
messageFactory.createSignedProposalPayload(roundIdentifier, block).getSignedPayload());
messageFactory.createProposal(roundIdentifier, block).getSignedPayload());
validator.validateNewRoundMessage(message);
verify(payloadValidator, times(1)).validateNewRoundMessage(message.getSignedPayload());

@ -96,21 +96,19 @@ public class NewRoundSignedDataValidatorTest {
final RoundChangeCertificate.Builder builder = new RoundChangeCertificate.Builder();
builder.appendRoundChangeMessage(
proposerMessageFactory.createSignedRoundChangePayload(roundIdentifier, Optional.empty()));
proposerMessageFactory.createRoundChange(roundIdentifier, Optional.empty()));
return messageCreator.createSignedNewRoundPayload(
return messageCreator.createNewRound(
roundIdentifier,
builder.buildCertificate(),
messageCreator
.createSignedProposalPayload(roundIdentifier, proposedBlock)
.getSignedPayload());
messageCreator.createProposal(roundIdentifier, proposedBlock).getSignedPayload());
}
private NewRound signPayload(final NewRoundPayload payload, final KeyPair signingKey) {
final MessageFactory messageCreator = new MessageFactory(signingKey);
return messageCreator.createSignedNewRoundPayload(
return messageCreator.createNewRound(
payload.getRoundIdentifier(),
payload.getRoundChangeCertificate(),
payload.getProposalPayload());
@ -167,17 +165,15 @@ public class NewRoundSignedDataValidatorTest {
final TerminatedRoundArtefacts mismatchedRoundArtefacts =
new TerminatedRoundArtefacts(
proposerMessageFactory.createSignedProposalPayload(preparedRound, prevProposedBlock),
proposerMessageFactory.createProposal(preparedRound, prevProposedBlock),
singletonList(
validatorMessageFactory.createSignedPreparePayload(
preparedRound, prevProposedBlock.getHash())));
validatorMessageFactory.createPrepare(preparedRound, prevProposedBlock.getHash())));
msgBuilder.setRoundChangeCertificate(
new RoundChangeCertificate(
singletonList(
validatorMessageFactory
.createSignedRoundChangePayload(
roundIdentifier, Optional.of(mismatchedRoundArtefacts))
.createRoundChange(roundIdentifier, Optional.of(mismatchedRoundArtefacts))
.getSignedPayload())));
final NewRound invalidMsg = signPayload(msgBuilder.build(), proposerKey);
@ -191,9 +187,9 @@ public class NewRoundSignedDataValidatorTest {
final RoundChangeCertificate.Builder roundChangeBuilder = new RoundChangeCertificate.Builder();
roundChangeBuilder.appendRoundChangeMessage(
proposerMessageFactory.createSignedRoundChangePayload(roundIdentifier, Optional.empty()));
proposerMessageFactory.createRoundChange(roundIdentifier, Optional.empty()));
roundChangeBuilder.appendRoundChangeMessage(
proposerMessageFactory.createSignedRoundChangePayload(prevRound, Optional.empty()));
proposerMessageFactory.createRoundChange(prevRound, Optional.empty()));
msgBuilder.setRoundChangeCertificate(roundChangeBuilder.buildCertificate());
@ -208,13 +204,13 @@ public class NewRoundSignedDataValidatorTest {
final RoundChangeCertificate.Builder roundChangeBuilder = new RoundChangeCertificate.Builder();
roundChangeBuilder.appendRoundChangeMessage(
proposerMessageFactory.createSignedRoundChangePayload(
proposerMessageFactory.createRoundChange(
roundIdentifier,
Optional.of(
new TerminatedRoundArtefacts(
proposerMessageFactory.createSignedProposalPayload(prevRound, proposedBlock),
proposerMessageFactory.createProposal(prevRound, proposedBlock),
Lists.newArrayList(
validatorMessageFactory.createSignedPreparePayload(
validatorMessageFactory.createPrepare(
prevRound, proposedBlock.getHash()))))));
msgBuilder.setRoundChangeCertificate(roundChangeBuilder.buildCertificate());
@ -233,13 +229,13 @@ public class NewRoundSignedDataValidatorTest {
new ConsensusRoundIdentifier(
roundIdentifier.getSequenceNumber(), roundIdentifier.getRoundNumber() - 1);
final Proposal latterProposal =
proposerMessageFactory.createSignedProposalPayload(latterPrepareRound, proposedBlock);
proposerMessageFactory.createProposal(latterPrepareRound, proposedBlock);
final Optional<TerminatedRoundArtefacts> preparedCert =
Optional.of(
new TerminatedRoundArtefacts(
latterProposal,
Lists.newArrayList(
validatorMessageFactory.createSignedPreparePayload(
validatorMessageFactory.createPrepare(
roundIdentifier, proposedBlock.getHash()))));
// An earlier PrepareCert is added to ensure the path to find the latest PrepareCert
@ -250,34 +246,34 @@ public class NewRoundSignedDataValidatorTest {
new ConsensusRoundIdentifier(
roundIdentifier.getSequenceNumber(), roundIdentifier.getRoundNumber() - 2);
final Proposal earlierProposal =
proposerMessageFactory.createSignedProposalPayload(earlierPreparedRound, earlierBlock);
proposerMessageFactory.createProposal(earlierPreparedRound, earlierBlock);
final Optional<TerminatedRoundArtefacts> earlierPreparedCert =
Optional.of(
new TerminatedRoundArtefacts(
earlierProposal,
Lists.newArrayList(
validatorMessageFactory.createSignedPreparePayload(
validatorMessageFactory.createPrepare(
earlierPreparedRound, earlierBlock.getHash()))));
final RoundChangeCertificate roundChangeCert =
new RoundChangeCertificate(
Lists.newArrayList(
proposerMessageFactory
.createSignedRoundChangePayload(roundIdentifier, earlierPreparedCert)
.createRoundChange(roundIdentifier, earlierPreparedCert)
.getSignedPayload(),
validatorMessageFactory
.createSignedRoundChangePayload(roundIdentifier, preparedCert)
.createRoundChange(roundIdentifier, preparedCert)
.getSignedPayload()));
// Ensure a message containing the earlier proposal fails
final NewRound newRoundWithEarlierProposal =
proposerMessageFactory.createSignedNewRoundPayload(
proposerMessageFactory.createNewRound(
roundIdentifier, roundChangeCert, earlierProposal.getSignedPayload());
assertThat(validator.validateNewRoundMessage(newRoundWithEarlierProposal.getSignedPayload()))
.isFalse();
final NewRound newRoundWithLatterProposal =
proposerMessageFactory.createSignedNewRoundPayload(
proposerMessageFactory.createNewRound(
roundIdentifier, roundChangeCert, latterProposal.getSignedPayload());
assertThat(validator.validateNewRoundMessage(newRoundWithLatterProposal.getSignedPayload()))
.isTrue();
@ -287,19 +283,18 @@ public class NewRoundSignedDataValidatorTest {
public void embeddedProposalFailsValidation() {
when(signedDataValidator.addSignedProposalPayload(any())).thenReturn(false, true);
final Proposal proposal =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, proposedBlock);
final Proposal proposal = proposerMessageFactory.createProposal(roundIdentifier, proposedBlock);
final NewRound msg =
proposerMessageFactory.createSignedNewRoundPayload(
proposerMessageFactory.createNewRound(
roundIdentifier,
new RoundChangeCertificate(
Lists.newArrayList(
proposerMessageFactory
.createSignedRoundChangePayload(roundIdentifier, Optional.empty())
.createRoundChange(roundIdentifier, Optional.empty())
.getSignedPayload(),
validatorMessageFactory
.createSignedRoundChangePayload(roundIdentifier, Optional.empty())
.createRoundChange(roundIdentifier, Optional.empty())
.getSignedPayload())),
proposal.getSignedPayload());

@ -42,8 +42,7 @@ public class RoundChangeMessageValidatorTest {
@Test
public void underlyingPayloadValidatorIsInvokedWithCorrectParameters() {
final RoundChange message =
messageFactory.createSignedRoundChangePayload(roundIdentifier, empty());
final RoundChange message = messageFactory.createRoundChange(roundIdentifier, empty());
validator.validateRoundChange(message);
verify(payloadValidator, times(1)).validateRoundChange(message.getSignedPayload());

@ -82,14 +82,13 @@ public class RoundChangeSignedDataValidatorTest {
@Test
public void roundChangeSentByNonValidatorFails() {
final RoundChange msg =
nonValidatorMessageFactory.createSignedRoundChangePayload(targetRound, Optional.empty());
nonValidatorMessageFactory.createRoundChange(targetRound, Optional.empty());
assertThat(validator.validateRoundChange(msg.getSignedPayload())).isFalse();
}
@Test
public void roundChangeContainingNoCertificateIsSuccessful() {
final RoundChange msg =
proposerMessageFactory.createSignedRoundChangePayload(targetRound, Optional.empty());
final RoundChange msg = proposerMessageFactory.createRoundChange(targetRound, Optional.empty());
assertThat(validator.validateRoundChange(msg.getSignedPayload())).isTrue();
}
@ -98,14 +97,13 @@ public class RoundChangeSignedDataValidatorTest {
public void roundChangeContainingInvalidProposalFails() {
final TerminatedRoundArtefacts terminatedRoundArtefacts =
new TerminatedRoundArtefacts(
proposerMessageFactory.createSignedProposalPayload(currentRound, block),
Collections.emptyList());
proposerMessageFactory.createProposal(currentRound, block), Collections.emptyList());
final PreparedCertificate prepareCertificate =
terminatedRoundArtefacts.getPreparedCertificate();
final RoundChange msg =
proposerMessageFactory.createSignedRoundChangePayload(
proposerMessageFactory.createRoundChange(
targetRound, Optional.of(terminatedRoundArtefacts));
when(basicValidator.addSignedProposalPayload(any())).thenReturn(false);
@ -123,11 +121,10 @@ public class RoundChangeSignedDataValidatorTest {
public void roundChangeContainingValidProposalButNoPrepareMessagesFails() {
final TerminatedRoundArtefacts terminatedRoundArtefacts =
new TerminatedRoundArtefacts(
proposerMessageFactory.createSignedProposalPayload(currentRound, block),
Collections.emptyList());
proposerMessageFactory.createProposal(currentRound, block), Collections.emptyList());
final RoundChange msg =
proposerMessageFactory.createSignedRoundChangePayload(
proposerMessageFactory.createRoundChange(
targetRound, Optional.of(terminatedRoundArtefacts));
when(basicValidator.addSignedProposalPayload(any())).thenReturn(true);
@ -136,18 +133,17 @@ public class RoundChangeSignedDataValidatorTest {
@Test
public void roundChangeInvalidPrepareMessageFromProposerFails() {
final Prepare prepareMsg =
validatorMessageFactory.createSignedPreparePayload(currentRound, block.getHash());
final Prepare prepareMsg = validatorMessageFactory.createPrepare(currentRound, block.getHash());
final TerminatedRoundArtefacts terminatedRoundArtefacts =
new TerminatedRoundArtefacts(
proposerMessageFactory.createSignedProposalPayload(currentRound, block),
proposerMessageFactory.createProposal(currentRound, block),
Lists.newArrayList(prepareMsg));
when(basicValidator.addSignedProposalPayload(any())).thenReturn(true);
when(basicValidator.validatePrepareMessage(any())).thenReturn(false);
final RoundChange msg =
proposerMessageFactory.createSignedRoundChangePayload(
proposerMessageFactory.createRoundChange(
targetRound, Optional.of(terminatedRoundArtefacts));
assertThat(validator.validateRoundChange(msg.getSignedPayload())).isFalse();
@ -162,8 +158,7 @@ public class RoundChangeSignedDataValidatorTest {
new ConsensusRoundIdentifier(currentRound.getSequenceNumber() + 1, 1);
final RoundChange msg =
proposerMessageFactory.createSignedRoundChangePayload(
latterRoundIdentifier, Optional.empty());
proposerMessageFactory.createRoundChange(latterRoundIdentifier, Optional.empty());
assertThat(validator.validateRoundChange(msg.getSignedPayload())).isFalse();
verify(basicValidator, never()).validatePrepareMessage(any());
@ -175,15 +170,14 @@ public class RoundChangeSignedDataValidatorTest {
new ConsensusRoundIdentifier(
currentRound.getSequenceNumber(), currentRound.getRoundNumber() + 2);
final Prepare prepareMsg =
validatorMessageFactory.createSignedPreparePayload(futureRound, block.getHash());
final Prepare prepareMsg = validatorMessageFactory.createPrepare(futureRound, block.getHash());
final TerminatedRoundArtefacts terminatedRoundArtefacts =
new TerminatedRoundArtefacts(
proposerMessageFactory.createSignedProposalPayload(futureRound, block),
proposerMessageFactory.createProposal(futureRound, block),
Lists.newArrayList(prepareMsg));
final RoundChange msg =
proposerMessageFactory.createSignedRoundChangePayload(
proposerMessageFactory.createRoundChange(
targetRound, Optional.of(terminatedRoundArtefacts));
assertThat(validator.validateRoundChange(msg.getSignedPayload())).isFalse();
@ -194,18 +188,17 @@ public class RoundChangeSignedDataValidatorTest {
@Test
public void roundChangeWithPastProposalForCurrentHeightIsSuccessful() {
final Prepare prepareMsg =
validatorMessageFactory.createSignedPreparePayload(currentRound, block.getHash());
final Prepare prepareMsg = validatorMessageFactory.createPrepare(currentRound, block.getHash());
final TerminatedRoundArtefacts terminatedRoundArtefacts =
new TerminatedRoundArtefacts(
proposerMessageFactory.createSignedProposalPayload(currentRound, block),
proposerMessageFactory.createProposal(currentRound, block),
Lists.newArrayList(prepareMsg));
final PreparedCertificate prepareCertificate =
terminatedRoundArtefacts.getPreparedCertificate();
final RoundChange msg =
proposerMessageFactory.createSignedRoundChangePayload(
proposerMessageFactory.createRoundChange(
targetRound, Optional.of(terminatedRoundArtefacts));
when(basicValidator.addSignedProposalPayload(prepareCertificate.getProposalPayload()))

@ -103,8 +103,7 @@ public class SignedDataValidatorTest {
@Test
public void receivingAPrepareMessageBeforeProposalFails() {
final Prepare prepareMsg =
proposerMessageFactory.createSignedPreparePayload(roundIdentifier, Hash.ZERO);
final Prepare prepareMsg = proposerMessageFactory.createPrepare(roundIdentifier, Hash.ZERO);
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isFalse();
}
@ -112,7 +111,7 @@ public class SignedDataValidatorTest {
@Test
public void receivingACommitMessageBeforeProposalFails() {
final Commit commitMsg =
proposerMessageFactory.createSignedCommitPayload(
proposerMessageFactory.createCommit(
roundIdentifier, Hash.ZERO, SECP256K1.sign(block.getHash(), proposerKey));
assertThat(validator.validateCommmitMessage(commitMsg.getSignedPayload())).isFalse();
@ -121,7 +120,7 @@ public class SignedDataValidatorTest {
@Test
public void receivingProposalMessageFromNonProposerFails() {
final Proposal proposalMsg =
validatorMessageFactory.createSignedProposalPayload(roundIdentifier, mock(Block.class));
validatorMessageFactory.createProposal(roundIdentifier, mock(Block.class));
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isFalse();
}
@ -130,18 +129,17 @@ public class SignedDataValidatorTest {
public void receivingProposalMessageWithIllegalBlockFails() {
when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())).thenReturn(empty());
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, mock(Block.class));
proposerMessageFactory.createProposal(roundIdentifier, mock(Block.class));
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isFalse();
}
@Test
public void receivingPrepareFromProposerFails() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
final Prepare prepareMsg =
proposerMessageFactory.createSignedPreparePayload(roundIdentifier, block.getHash());
proposerMessageFactory.createPrepare(roundIdentifier, block.getHash());
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isFalse();
@ -149,11 +147,10 @@ public class SignedDataValidatorTest {
@Test
public void receivingPrepareFromNonValidatorFails() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
final Prepare prepareMsg =
nonValidatorMessageFactory.createSignedPreparePayload(roundIdentifier, block.getHash());
nonValidatorMessageFactory.createPrepare(roundIdentifier, block.getHash());
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isFalse();
@ -161,16 +158,15 @@ public class SignedDataValidatorTest {
@Test
public void receivingMessagesWithDifferentRoundIdFromProposalFails() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
final ConsensusRoundIdentifier invalidRoundIdentifier =
new ConsensusRoundIdentifier(
roundIdentifier.getSequenceNumber(), roundIdentifier.getRoundNumber() + 1);
final Prepare prepareMsg =
validatorMessageFactory.createSignedPreparePayload(invalidRoundIdentifier, block.getHash());
validatorMessageFactory.createPrepare(invalidRoundIdentifier, block.getHash());
final Commit commitMsg =
validatorMessageFactory.createSignedCommitPayload(
validatorMessageFactory.createCommit(
invalidRoundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), proposerKey));
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
@ -180,10 +176,9 @@ public class SignedDataValidatorTest {
@Test
public void receivingPrepareNonProposerValidatorWithCorrectRoundIsSuccessful() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
final Prepare prepareMsg =
validatorMessageFactory.createSignedPreparePayload(roundIdentifier, block.getHash());
validatorMessageFactory.createPrepare(roundIdentifier, block.getHash());
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
assertThat(validator.validatePrepareMessage(prepareMsg.getSignedPayload())).isTrue();
@ -191,11 +186,10 @@ public class SignedDataValidatorTest {
@Test
public void receivingACommitMessageWithAnInvalidCommitSealFails() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
final Commit commitMsg =
proposerMessageFactory.createSignedCommitPayload(
proposerMessageFactory.createCommit(
roundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), nonValidatorKey));
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
@ -204,15 +198,14 @@ public class SignedDataValidatorTest {
@Test
public void commitMessageContainingValidSealFromValidatorIsSuccessful() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
final Commit proposerCommitMsg =
proposerMessageFactory.createSignedCommitPayload(
proposerMessageFactory.createCommit(
roundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), proposerKey));
final Commit validatorCommitMsg =
validatorMessageFactory.createSignedCommitPayload(
validatorMessageFactory.createCommit(
roundIdentifier, block.getHash(), SECP256K1.sign(block.getHash(), validatorKey));
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
@ -222,35 +215,32 @@ public class SignedDataValidatorTest {
@Test
public void subsequentProposalHasDifferentSenderFails() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
final Proposal secondProposalMsg =
validatorMessageFactory.createSignedProposalPayload(roundIdentifier, block);
validatorMessageFactory.createProposal(roundIdentifier, block);
assertThat(validator.addSignedProposalPayload(secondProposalMsg.getSignedPayload())).isFalse();
}
@Test
public void subsequentProposalHasDifferentContentFails() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
final ConsensusRoundIdentifier newRoundIdentifier = new ConsensusRoundIdentifier(3, 0);
final Proposal secondProposalMsg =
proposerMessageFactory.createSignedProposalPayload(newRoundIdentifier, block);
proposerMessageFactory.createProposal(newRoundIdentifier, block);
assertThat(validator.addSignedProposalPayload(secondProposalMsg.getSignedPayload())).isFalse();
}
@Test
public void subsequentProposalHasIdenticalSenderAndContentIsSuccessful() {
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isTrue();
final Proposal secondProposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
proposerMessageFactory.createProposal(roundIdentifier, block);
assertThat(validator.addSignedProposalPayload(secondProposalMsg.getSignedPayload())).isTrue();
}
@ -258,8 +248,7 @@ public class SignedDataValidatorTest {
public void blockRoundMisMatchWithMessageRoundFails() {
insertRoundToBlockHeader(roundIdentifier.getRoundNumber() + 1);
final Proposal proposalMsg =
proposerMessageFactory.createSignedProposalPayload(roundIdentifier, block);
final Proposal proposalMsg = proposerMessageFactory.createProposal(roundIdentifier, block);
assertThat(validator.addSignedProposalPayload(proposalMsg.getSignedPayload())).isFalse();
}

Loading…
Cancel
Save