@Test void shouldProgressWhenThereAreManyEmptyBatchesInARow() { assertThat(sync.syncToChain(targetChain)).isNotDone(); final int initialBatchCount = batches.size(); for (int i = 0; i < initialBatchCount; i++) { batches.receiveBlocks(batches.get(i)); } assertThat(batches).hasSizeGreaterThan(initialBatchCount); final Batch laterBatch = batches.get(initialBatchCount); batches.receiveBlocks( laterBatch, chainBuilder.generateBlockAtSlot(laterBatch.getFirstSlot()).getBlock()); verifyNoInteractions(batchImporter); assertBatchActive(batches.get(0)); final Batch confirmingBatch = batches.get(initialBatchCount + 1); batches.receiveBlocks( confirmingBatch, chainBuilder.generateBlockAtSlot(confirmingBatch.getFirstSlot()).getBlock()); assertBatchImported(laterBatch); batches.getImportResult(laterBatch).complete(IMPORTED_ALL_BLOCKS); for (int i = 0; i <= initialBatchCount; i++) { assertBatchNotActive(batches.get(i)); } }
@Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); static BatchSync create(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchImporter batchImporter,
      final BatchFactory batchFactory,
      final UInt64 batchSize); @Override SafeFuture<SyncResult> syncToChain(final TargetChain targetChain); }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); static BatchSync create(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchImporter batchImporter,
      final BatchFactory batchFactory,
      final UInt64 batchSize); @Override SafeFuture<SyncResult> syncToChain(final TargetChain targetChain);  }