@Test void shouldConfirmAndImportBatchWhenItEndsWithTargetChainHeadBlock() { final UInt64 headSlot = BATCH_SIZE.times(2).minus(5); final SignedBeaconBlock block3 = chainBuilder.generateBlockAtSlot(3).getBlock(); final SignedBeaconBlock headBlock = chainBuilder.generateBlockAtSlot(headSlot).getBlock(); targetChain = chainWith(new SlotAndBlockRoot(headSlot, headBlock.getRoot()), syncSource); final SafeFuture<SyncResult> result = sync.syncToChain(targetChain); assertThat(result).isNotDone(); assertThat(batches).hasSize(2); final Batch batch1 = batches.get(0); final Batch batch2 = batches.get(1); batches.receiveBlocks(batch1, block3); batches.receiveBlocks(batch2, headBlock); assertThat(result).isNotDone(); assertBatchImported(batch1); batches.getImportResult(batch1).complete(IMPORTED_ALL_BLOCKS); assertThat(result).isNotDone(); assertBatchImported(batch2); batches.getImportResult(batch2).complete(IMPORTED_ALL_BLOCKS); assertThat(result).isCompletedWithValue(SyncResult.COMPLETE); }
@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);  }