@Test
  public void sequenceTest() throws InterruptedException {
    IndexController controller =
        new IndexController(storageDir.getAbsolutePath(), peer, 0, CHECK_POINT_GAP);
    Assert.assertEquals(0, controller.getCurrentIndex());

    SyncStatus status = new SyncStatus(controller, config);
    List<Batch> batchList = new ArrayList<>();

    for (long i = 0; i < config.getReplication().getMaxPendingBatchesNum(); i++) {
      TLogEntry logEntry = new TLogEntry();
      logEntry.setSearchIndex(i);
      Batch batch = new Batch(IoTConsensusConfig.newBuilder().build());
      batch.addTLogEntry(logEntry);
      batch.buildIndex();
      batchList.add(batch);
      status.addNextBatch(batch);
    }

    for (int i = 0; i < config.getReplication().getMaxPendingBatchesNum(); i++) {
      status.removeBatch(batchList.get(i));
      Assert.assertEquals(
          config.getReplication().getMaxPendingBatchesNum() - 1 - i,
          status.getPendingBatches().size());
      Assert.assertEquals(i, controller.getCurrentIndex());
      Assert.assertEquals(
          config.getReplication().getMaxPendingBatchesNum(), status.getNextSendingIndex());
    }
  }
Confirm success from front to back.
iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/iot/logdispatcher/SyncStatusTest.java