Skip to content

Commit

Permalink
fixing a unit test behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Wertz <edward@swirldslabs.com>
  • Loading branch information
edward-swirldslabs committed Dec 2, 2024
1 parent 85c006c commit e64652b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.swirlds.platform.system.address.AddressBook;
import com.swirlds.platform.system.events.ConsensusEvent;
import com.swirlds.platform.system.status.actions.FreezePeriodEnteredAction;
import com.swirlds.platform.system.status.actions.SelfEventReachedConsensusAction;
import com.swirlds.platform.test.fixtures.addressbook.RandomAddressBookBuilder;
import com.swirlds.platform.test.fixtures.event.TestingEventBuilder;
import com.swirlds.platform.wiring.components.StateAndRound;
Expand Down Expand Up @@ -119,7 +120,12 @@ void normalOperation(final boolean pcesRound) throws InterruptedException {
handlerOutput.reservedSignedState().get().getReservationCount(),
"state should be returned with a reservation");

assertTrue(tester.getSubmittedActions().isEmpty(), "no status should have been submitted");
// only the self event reaching consensus should be reported, no freeze action.
assertEquals(1, tester.getSubmittedActions().size(), "the freeze status should have been submitted");
assertEquals(
SelfEventReachedConsensusAction.class,
tester.getSubmittedActions().getFirst().getClass());

assertEquals(1, tester.getHandledRounds().size(), "a round should have been handled");
assertSame(
consensusRound,
Expand Down Expand Up @@ -167,8 +173,9 @@ void freezeHandling() throws InterruptedException {
1,
handlerOutput.reservedSignedState().get().getReservationCount(),
"state should be returned with a reservation");

assertEquals(1, tester.getSubmittedActions().size(), "the freeze status should have been submitted");
// In addition to the freeze action, the uptime tracker reports a self event coming to consensus in the round.
assertEquals(2, tester.getSubmittedActions().size(), "the freeze status should have been submitted");
// The freeze action is the first action submitted.
assertEquals(
FreezePeriodEnteredAction.class,
tester.getSubmittedActions().getFirst().getClass());
Expand All @@ -181,7 +188,7 @@ void freezeHandling() throws InterruptedException {
tester.getTransactionHandler().handleConsensusRound(postFreezeConsensusRound);
assertNull(postFreezeOutput, "no state should be created after freeze period");

assertEquals(1, tester.getSubmittedActions().size(), "no new status should have been submitted");
assertEquals(2, tester.getSubmittedActions().size(), "no new status should have been submitted");
assertEquals(1, tester.getHandledRounds().size(), "no new rounds should have been handled");
assertSame(consensusRound, tester.getHandledRounds().getFirst(), "it should same round as before");
assertEquals(
Expand Down

0 comments on commit e64652b

Please sign in to comment.