### Question:
ThrottlingEth1Provider implements Eth1Provider { @Override public SafeFuture<Block> getEth1Block(final UInt64 blockNumber) { return queueRequest(() -> delegate.getEth1Block(blockNumber)); } ThrottlingEth1Provider(final Eth1Provider delegate, final int maximumConcurrentRequests); @Override SafeFuture<Block> getEth1Block(final UInt64 blockNumber); @Override SafeFuture<Block> getGuaranteedEth1Block(final String blockHash); @Override SafeFuture<Block> getGuaranteedEth1Block(final UInt64 blockNumber); @Override SafeFuture<Block> getEth1Block(final String blockHash); @Override SafeFuture<Block> getLatestEth1Block(); @Override SafeFuture<EthCall> ethCall(
      final String from, final String to, final String data, final UInt64 blockNumber);  }### Answer:
@Test void shouldLimitNumberOfInFlightRequests() { provider.getEth1Block(ONE).reportExceptions(); provider.getEth1Block(TWO).reportExceptions(); provider.getEth1Block(THREE).reportExceptions(); provider.getEth1Block(FOUR).reportExceptions(); verify(delegateProvider).getEth1Block(ONE); verify(delegateProvider).getEth1Block(TWO); verify(delegateProvider).getEth1Block(THREE); verifyNoMoreInteractions(delegateProvider); }
@Test void shouldProcessNextRequestWhenInFlightOneCompletes() { final SafeFuture<Block> request1 = provider.getEth1Block(ONE); final SafeFuture<Block> request2 = provider.getEth1Block(TWO); final SafeFuture<Block> request3 = provider.getEth1Block(THREE); final SafeFuture<Block> request4 = provider.getEth1Block(FOUR); verify(delegateProvider).getEth1Block(ONE); verify(delegateProvider).getEth1Block(TWO); verify(delegateProvider).getEth1Block(THREE); verifyNoMoreInteractions(delegateProvider); blockRequests.get(1).complete(block2); assertThat(request1).isNotDone(); assertThat(request2).isCompletedWithValue(block2); assertThat(request3).isNotDone(); assertThat(request4).isNotDone(); verify(delegateProvider).getEth1Block(FOUR); blockRequests.get(0).complete(block1); assertThat(request1).isCompletedWithValue(block1); assertThat(request2).isCompletedWithValue(block2); assertThat(request3).isNotDone(); assertThat(request4).isNotDone(); verifyNoMoreInteractions(delegateProvider); }