Skip to content

Commit

Permalink
Remove unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Dec 30, 2024
1 parent bff7a5e commit 26e0529
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,13 @@ public void requestBlobSidecars_shouldFailBeforeDenebMilestone() {
.hasMessageContaining("BlobSidecarsByRoot method is not supported");
}

@TestTemplate
public void requestBlobSidecar_shouldFailBeforeDenebMilestone() {
assumeThat(specMilestone).isLessThan(SpecMilestone.DENEB);
assertThatThrownBy(
() -> requestBlobSidecarByRoot(peer, new BlobIdentifier(Bytes32.ZERO, UInt64.ZERO)))
.hasRootCauseInstanceOf(UnsupportedOperationException.class)
.hasMessageContaining("BlobSidecarsByRoot method is not supported");
}

@TestTemplate
public void requestBlobSidecars_shouldReturnEmptyBlobSidecarsAfterDenebMilestone()
throws ExecutionException, InterruptedException, TimeoutException {
assumeThat(specMilestone).isGreaterThanOrEqualTo(DENEB);
final Optional<BlobSidecar> blobSidecar =
requestBlobSidecarByRoot(peer, new BlobIdentifier(Bytes32.ZERO, UInt64.ZERO));
assertThat(blobSidecar).isEmpty();
final List<BlobSidecar> blobSidecars =
requestBlobSidecarsByRoot(peer, List.of(new BlobIdentifier(Bytes32.ZERO, UInt64.ZERO)));
assertThat(blobSidecars).isEmpty();
}

@TestTemplate
Expand Down Expand Up @@ -117,13 +108,4 @@ private List<BlobSidecar> requestBlobSidecarsByRoot(
assertThat(peer.getOutstandingRequests()).isEqualTo(0);
return blobSidecars;
}

private Optional<BlobSidecar> requestBlobSidecarByRoot(
final Eth2Peer peer, final BlobIdentifier blobIdentifier)
throws ExecutionException, InterruptedException, TimeoutException {
final Optional<BlobSidecar> blobSidecar =
waitFor(peer.requestBlobSidecarByRoot(blobIdentifier));
assertThat(peer.getOutstandingRequests()).isEqualTo(0);
return blobSidecar;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.common.base.MoreObjects;
import com.google.common.base.Suppliers;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -37,7 +36,6 @@
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.BeaconChainMethods;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.BlobSidecarsByRangeListenerValidatingProxy;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.BlobSidecarsByRootListenerValidatingProxy;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.BlobSidecarsByRootValidator;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.BlocksByRangeListenerWrapper;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.MetadataMessagesFactory;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.StatusMessageFactory;
Expand Down Expand Up @@ -280,32 +278,6 @@ public SafeFuture<Optional<SignedBeaconBlock>> requestBlockByRoot(final Bytes32
List.of(blockRoot)));
}

@Override
public SafeFuture<Optional<BlobSidecar>> requestBlobSidecarByRoot(
final BlobIdentifier blobIdentifier) {
return rpcMethods
.blobSidecarsByRoot()
.map(
method -> {
final List<BlobIdentifier> blobIdentifiers =
Collections.singletonList(blobIdentifier);
return requestOptionalItem(
method,
new BlobSidecarsByRootRequestMessage(
blobSidecarsByRootRequestMessageSchema.get(), blobIdentifiers))
.thenPeek(
maybeBlobSidecar ->
maybeBlobSidecar.ifPresent(
blobSidecar -> {
final BlobSidecarsByRootValidator validator =
new BlobSidecarsByRootValidator(
this, spec, kzg, blobIdentifiers);
validator.validate(blobSidecar);
}));
})
.orElse(failWithUnsupportedMethodException("BlobSidecarsByRoot"));
}

@Override
public SafeFuture<Void> requestBlocksByRange(
final UInt64 startSlot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ SafeFuture<Void> requestBlobSidecarsByRoot(

SafeFuture<Optional<SignedBeaconBlock>> requestBlockByRoot(Bytes32 blockRoot);

SafeFuture<Optional<BlobSidecar>> requestBlobSidecarByRoot(BlobIdentifier blobIdentifier);

SafeFuture<MetadataMessage> requestMetadata();

<I extends RpcRequest, O extends SszData> SafeFuture<O> requestSingleItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,35 +200,6 @@ public void shouldSendRequest_BlobSidecarsByRoot() {
assertThat(request.getMaximumResponseChunks()).isEqualTo(3);
}

@Test
@SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
public void shouldSendRequest_BlobSidecarByRoot() {

final Eth2RpcMethod<BlobSidecarsByRootRequestMessage, BlobSidecar> blobSidecarsByRootMethod =
mock(Eth2RpcMethod.class);

final RpcStreamController<RpcRequestHandler> rpcStreamController =
mock(RpcStreamController.class);

when(rpcMethods.blobSidecarsByRoot()).thenReturn(Optional.of(blobSidecarsByRootMethod));

when(peer.sendRequest(any(), any(), any()))
.thenReturn(SafeFuture.completedFuture(rpcStreamController));

final BlobIdentifier blobIdentifier = dataStructureUtil.randomBlobIdentifier();

peer.requestBlobSidecarByRoot(blobIdentifier);

final ArgumentCaptor<BlobSidecarsByRootRequestMessage> requestCaptor =
ArgumentCaptor.forClass(BlobSidecarsByRootRequestMessage.class);

verify(delegate, times(1)).sendRequest(any(), requestCaptor.capture(), any());

final BlobSidecarsByRootRequestMessage request = requestCaptor.getValue();

assertThat(request.getMaximumResponseChunks()).isEqualTo(1);
}

@Test
@SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
public void shouldNotUpdateRequestWhenWithinDeneb_BlobSidecarsByRange() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,6 @@ public SafeFuture<Optional<SignedBeaconBlock>> requestBlockByRoot(final Bytes32
return createPendingBlockRequest(handler);
}

@Override
public SafeFuture<Optional<BlobSidecar>> requestBlobSidecarByRoot(
final BlobIdentifier blobIdentifier) {
final PendingRequestHandler<Optional<BlobSidecar>, BlobSidecar> handler =
PendingRequestHandler.createForSingleBlobSidecarRequest(
() -> findBlobSidecarByBlobIdentifier(blobIdentifier));

return createPendingBlobSidecarRequest(handler);
}

private <T> SafeFuture<T> createPendingBlockRequest(
final PendingRequestHandler<T, SignedBeaconBlock> handler) {
final PendingRequestHandler<T, SignedBeaconBlock> filteredHandler =
Expand Down

0 comments on commit 26e0529

Please sign in to comment.