Skip to content

Commit

Permalink
Add getRetiringFederationAddress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-zack committed Jun 14, 2024
1 parent 4c7174c commit 7f57d1b
Showing 1 changed file with 64 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,13 @@ void getRetiringFederation_returnsNull() {
Federation retiringFederation = federationSupport.getRetiringFederation();
assertThat(retiringFederation, is(nullValue()));
}

@Test
@Tag("getRetiringFederationAddress")
void getRetiringFederationAddress_returnsNull() {
Address retiringFederationAddress = federationSupport.getRetiringFederationAddress();
assertThat(retiringFederationAddress, is(nullValue()));
}
}

@Nested
Expand Down Expand Up @@ -825,6 +832,13 @@ void getRetiringFederation_returnsNull() {
Federation retiringFederation = federationSupport.getRetiringFederation();
assertThat(retiringFederation, is(nullValue()));
}

@Test
@Tag("getRetiringFederationAddress")
void getRetiringFederationAddress_returnsNull() {
Address retiringFederationAddress = federationSupport.getRetiringFederationAddress();
assertThat(retiringFederationAddress, is(nullValue()));
}
}

@Nested
Expand Down Expand Up @@ -889,14 +903,6 @@ void getRetiringFederation_withNewFederationNotActive_returnsNull(
assertThat(retiringFederation, is(nullValue()));
}

private Stream<Arguments> newFederationNotActiveActivationArgs() {
return Stream.of(
Arguments.of(blockNumberFederationActivationHop - 1, hopActivations),
Arguments.of(blockNumberFederationActivationHop, fingerrootActivations),
Arguments.of(blockNumberFederationActivationFingerroot - 1, fingerrootActivations)
);
}

@ParameterizedTest
@Tag("getRetiringFederation")
@MethodSource("newFederationActiveActivationArgs")
Expand All @@ -918,6 +924,56 @@ void getRetiringFederation_withNewFederationActive_returnsOldFederation(
assertThat(retiringFederation, is(oldFederation));
}

@ParameterizedTest
@Tag("getRetiringFederationAddress")
@MethodSource("newFederationNotActiveActivationArgs")
void getRetiringFederationAddress_withNewFederationNotActive_returnsNull(
long currentBlock,
ActivationConfig.ForBlock activations) {

Block executionBlock = mock(Block.class);
when(executionBlock.getNumber()).thenReturn(currentBlock);

federationSupport = federationSupportBuilder
.withFederationConstants(federationMainnetConstants)
.withFederationStorageProvider(storageProvider)
.withRskExecutionBlock(executionBlock)
.withActivations(activations)
.build();

Address retiringFederationAddress = federationSupport.getRetiringFederationAddress();
assertThat(retiringFederationAddress, is(nullValue()));
}

@ParameterizedTest
@Tag("getRetiringFederation")
@MethodSource("newFederationActiveActivationArgs")
void getRetiringFederationAddress_withNewFederationActive_returnsOldFederationAddress(
long currentBlock,
ActivationConfig.ForBlock activations) {

Block executionBlock = mock(Block.class);
when(executionBlock.getNumber()).thenReturn(currentBlock);

federationSupport = federationSupportBuilder
.withFederationConstants(federationMainnetConstants)
.withFederationStorageProvider(storageProvider)
.withRskExecutionBlock(executionBlock)
.withActivations(activations)
.build();

Address retiringFederationAddress = federationSupport.getRetiringFederationAddress();
assertThat(retiringFederationAddress, is(oldFederation.getAddress()));
}

private Stream<Arguments> newFederationNotActiveActivationArgs() {
return Stream.of(
Arguments.of(blockNumberFederationActivationHop - 1, hopActivations),
Arguments.of(blockNumberFederationActivationHop, fingerrootActivations),
Arguments.of(blockNumberFederationActivationFingerroot - 1, fingerrootActivations)
);
}

private Stream<Arguments> newFederationActiveActivationArgs() {
return Stream.of(
Arguments.of(blockNumberFederationActivationHop, hopActivations),
Expand Down

0 comments on commit 7f57d1b

Please sign in to comment.