|
|
|
@ -84,7 +84,8 @@ public class IbftRoundTest { |
|
|
|
|
private Block proposedBlock; |
|
|
|
|
private IbftExtraData proposedExtraData; |
|
|
|
|
|
|
|
|
|
final Signature remoteCommitSeal = Signature.create(BigInteger.ONE, BigInteger.ONE, (byte) 1); |
|
|
|
|
private final Signature remoteCommitSeal = |
|
|
|
|
Signature.create(BigInteger.ONE, BigInteger.ONE, (byte) 1); |
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
public void setup() { |
|
|
|
@ -105,11 +106,11 @@ public class IbftRoundTest { |
|
|
|
|
Optional.empty(), |
|
|
|
|
0, |
|
|
|
|
Collections.emptyList()); |
|
|
|
|
BlockHeaderTestFixture headerTestFixture = new BlockHeaderTestFixture(); |
|
|
|
|
final BlockHeaderTestFixture headerTestFixture = new BlockHeaderTestFixture(); |
|
|
|
|
headerTestFixture.extraData(proposedExtraData.encode()); |
|
|
|
|
headerTestFixture.number(1); |
|
|
|
|
|
|
|
|
|
BlockHeader header = headerTestFixture.buildHeader(); |
|
|
|
|
final BlockHeader header = headerTestFixture.buildHeader(); |
|
|
|
|
proposedBlock = |
|
|
|
|
new Block(header, new BlockBody(Collections.emptyList(), Collections.emptyList())); |
|
|
|
|
|
|
|
|
@ -281,9 +282,6 @@ public class IbftRoundTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void aNewRoundMessageWithTheSameBlockIsSentUponReceptionOfARoundChangeWithCertificate() { |
|
|
|
|
SignedData<ProposalPayload> mockedSentMessage = |
|
|
|
|
messageFactory.createSignedProposalPayload(roundIdentifier, proposedBlock); |
|
|
|
|
|
|
|
|
|
final ConsensusRoundIdentifier priorRoundChange = new ConsensusRoundIdentifier(1, 0); |
|
|
|
|
final RoundState roundState = new RoundState(roundIdentifier, 2, messageValidator); |
|
|
|
|
final IbftRound round = |
|
|
|
@ -319,5 +317,42 @@ public class IbftRoundTest { |
|
|
|
|
IbftExtraData.decode( |
|
|
|
|
payloadArgCaptor.getValue().getPayload().getBlock().getHeader().getExtraData()); |
|
|
|
|
assertThat(proposedExtraData.getRound()).isEqualTo(roundIdentifier.getRoundNumber()); |
|
|
|
|
|
|
|
|
|
// 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())); |
|
|
|
|
assertThat(roundState.isPrepared()).isTrue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void creatingNewBlockFromEmptyPreparedCertificateUpdatesInternalState() { |
|
|
|
|
final RoundState roundState = new RoundState(roundIdentifier, 2, messageValidator); |
|
|
|
|
final IbftRound round = |
|
|
|
|
new IbftRound( |
|
|
|
|
roundState, |
|
|
|
|
blockCreator, |
|
|
|
|
protocolContext, |
|
|
|
|
blockImporter, |
|
|
|
|
subscribers, |
|
|
|
|
localNodeKeys, |
|
|
|
|
messageFactory, |
|
|
|
|
transmitter); |
|
|
|
|
|
|
|
|
|
final RoundChangeCertificate roundChangeCertificate = |
|
|
|
|
new RoundChangeCertificate( |
|
|
|
|
Collections.singletonList( |
|
|
|
|
messageFactory.createSignedRoundChangePayload(roundIdentifier, Optional.empty()))); |
|
|
|
|
|
|
|
|
|
round.startRoundWith(roundChangeCertificate, 15); |
|
|
|
|
verify(transmitter, times(1)) |
|
|
|
|
.multicastNewRound( |
|
|
|
|
eq(roundIdentifier), eq(roundChangeCertificate), payloadArgCaptor.capture()); |
|
|
|
|
|
|
|
|
|
// 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())); |
|
|
|
|
assertThat(roundState.isPrepared()).isTrue(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|