Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getRetiringFederationAddress tests #2494

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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