Skip to content

Commit

Permalink
7311: Remove unused code, update tests to use used code (#7772)
Browse files Browse the repository at this point in the history
* 7311: Remove unused code, update tests to use used code

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 7311: Disable invalid test

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

---------

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
  • Loading branch information
Matilda-Clerke authored Oct 15, 2024
1 parent e720d8f commit acfbc82
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class GetReceiptsForHeadersTask
extends AbstractRetryingPeerTask<Map<BlockHeader, List<TransactionReceipt>>> {
private static final Logger LOG = LoggerFactory.getLogger(GetReceiptsForHeadersTask.class);
private static final int DEFAULT_RETRIES = 5;
protected static final int DEFAULT_RETRIES = 5;

private final EthContext ethContext;

Expand All @@ -65,14 +65,6 @@ private GetReceiptsForHeadersTask(
completeEmptyReceipts(headers);
}

public static GetReceiptsForHeadersTask forHeaders(
final EthContext ethContext,
final List<BlockHeader> headers,
final int maxRetries,
final MetricsSystem metricsSystem) {
return new GetReceiptsForHeadersTask(ethContext, headers, maxRetries, metricsSystem);
}

public static GetReceiptsForHeadersTask forHeaders(
final EthContext ethContext,
final List<BlockHeader> headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@
import java.util.Map;

import com.google.common.collect.ImmutableMap;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class GetReceiptsForHeadersTaskTest
extends RetryingMessageTaskTest<Map<BlockHeader, List<TransactionReceipt>>> {

@BeforeEach
@Override
public void resetMaxRetries() {
maxRetries = GetReceiptsForHeadersTask.DEFAULT_RETRIES;
}

@Override
protected Map<BlockHeader, List<TransactionReceipt>> generateDataToBeRequested() {
// Setup data to be requested and expected response
Expand All @@ -50,8 +58,7 @@ protected Map<BlockHeader, List<TransactionReceipt>> generateDataToBeRequested()
protected EthTask<Map<BlockHeader, List<TransactionReceipt>>> createTask(
final Map<BlockHeader, List<TransactionReceipt>> requestedData) {
final List<BlockHeader> headersToComplete = new ArrayList<>(requestedData.keySet());
return GetReceiptsForHeadersTask.forHeaders(
ethContext, headersToComplete, maxRetries, metricsSystem);
return GetReceiptsForHeadersTask.forHeaders(ethContext, headersToComplete, metricsSystem);
}

@Test
Expand All @@ -68,4 +75,13 @@ public void shouldBeCompleteWhenAllReceiptsAreEmpty() {

assertThat(createTask(expected).run()).isCompletedWithValue(expected);
}

@Override
@Test
@Disabled
public void failsWhenPeerReturnsPartialResultThenStops() {
// Test is not valid when more than 4 retries are allowed, as is always the case with
// GetReceiptsForHeadersTask, because the peer is forcefully disconnected after failing
// too many times
}
}

0 comments on commit acfbc82

Please sign in to comment.