Skip to content

Commit

Permalink
Merge pull request #2956 from rsksmart/add_test_for_proposed_fed_crea…
Browse files Browse the repository at this point in the history
…tion_time_method

Add missing test for getProposedFederationCreationTime Bridge method
  • Loading branch information
marcos-iov authored Jan 24, 2025
2 parents db10a59 + 08e7a31 commit 26d8496
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions rskj-core/src/test/java/co/rsk/peg/BridgeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,43 @@ void getProposedFederationCreationTime(MessageCall.MsgType msgType, ActivationCo
}
}

@Test
void getProposedFederationCreationTime_shouldReturnValueFromSeconds() {
// arrange
ActivationConfig activationConfig = ActivationConfigsForTest.all();

BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
Bridge bridge = bridgeBuilder
.activationConfig(activationConfig)
.bridgeSupport(bridgeSupportMock)
.build();

long creationTimeInSeconds = 1000;
Instant creationTime = Instant.ofEpochSecond(creationTimeInSeconds);
when(bridgeSupportMock.getProposedFederationCreationTime()).thenReturn(Optional.of(creationTime));

// act & assert
assertEquals(creationTimeInSeconds, bridge.getProposedFederationCreationTime(new Object[]{}));
}

@Test
void getProposedFederationCreationTime_whenBridgeSupportReturnsEmpty_shouldReturnMinusOne() {
// arrange
ActivationConfig activationConfig = ActivationConfigsForTest.all();

BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
Bridge bridge = bridgeBuilder
.activationConfig(activationConfig)
.bridgeSupport(bridgeSupportMock)
.build();

when(bridgeSupportMock.getProposedFederationCreationTime()).thenReturn(Optional.empty());

// act & assert
long expectedCreationTime = -1L;
assertEquals(expectedCreationTime, bridge.getProposedFederationCreationTime(new Object[]{}));
}

@ParameterizedTest()
@MethodSource("msgTypesAndActivations")
void getProposedFederationCreationBlockNumber(MessageCall.MsgType msgType, ActivationConfig activationConfig) throws VMException {
Expand Down

0 comments on commit 26d8496

Please sign in to comment.