diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncPhaseTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncPhaseTest.java index a0a3d2e1a03..f2a7efc8f1f 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncPhaseTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncPhaseTest.java @@ -43,7 +43,6 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jetbrains.annotations.NotNull; @@ -70,7 +69,6 @@ public class BackwardSyncPhaseTest { private MutableBlockchain remoteBlockchain; private RespondingEthPeer peer; - GenericKeyValueStorageFacade headersStorage; GenericKeyValueStorageFacade blocksStorage; @@ -117,14 +115,10 @@ public void setup() { public void shouldWaitWhenTTDNotReached() throws ExecutionException, InterruptedException, TimeoutException { final BackwardChain backwardChain = createBackwardChain(LOCAL_HEIGHT + 3); - when(context.isOnTTD()).thenReturn(false); + when(context.isOnTTD()).thenReturn(false).thenReturn(false).thenReturn(true); BackwardSyncPhase step = new BackwardSyncPhase(context, backwardChain); - final CompletableFuture completableFuture = step.waitForTTD(); - assertThat(completableFuture.isDone()).isFalse(); - when(context.isOnTTD()).thenReturn(true); - - completableFuture.get(6, TimeUnit.SECONDS); - assertThat(completableFuture.isDone()).isFalse(); + step.waitForTTD(); + verify(context, Mockito.times(2)).getEthContext(); } @Test