empty.getNextAddress(new LedgerAddress(1, 1, 0), Long.MAX_VALUE));
LedgerAddress a = m.getNextAddress(new LedgerAddress(firstLedgerSeq - 1, firstLedgerId - 1, 1234), Long.MAX_VALUE);
Assert.assertEquals("Unexpected ledger id when input address less than first ledger.", firstLedgerId, a.getLedgerId());
Assert.assertEquals("Unexpected entry id when input address less than first ledger.", 0, a.getEntryId());
LedgerAddress truncationAddress = new LedgerAddress(secondLedgerSeq, secondLedgerId, 1);
val m2 = m.truncate(truncationAddress);
a = m2.getNextAddress(new LedgerAddress(firstLedgerSeq, firstLedgerId, 0), Long.MAX_VALUE);
Assert.assertEquals("Unexpected result when input address less than truncation address.", 0, truncationAddress.compareTo(a));
a = m.getNextAddress(new LedgerAddress(firstLedgerSeq, firstLedgerId, 0), 2);
Assert.assertEquals("Unexpected ledger id when result should be in the same ledger.", firstLedgerId, a.getLedgerId());
Assert.assertEquals("Unexpected entry id when result should be in the same ledger.", 1, a.getEntryId());
a = m.getNextAddress(new LedgerAddress(lm.getSequence(), lm.getLedgerId(), 3), 3);
if (i == m.getLedgers().size() - 1) {
Assert.assertNull("Unexpected result when reached the end of the log.", a);
a = m.getNextAddress(new LedgerAddress(firstLedgerSeq + 1, firstLedgerId + 1, 3), 3);
Assert.assertEquals("Unexpected ledger id when result should be in the next ledger.", secondLedgerId, a.getLedgerId());
Assert.assertEquals("Unexpected entry id when result should be in the next ledger.", 0, a.getEntryId());