Skip to main content

Checkpoint: the ledger, proven

Challenge on lesson: Checkpoint: The Ledger, Proven

CHALLENGE
Difficulty: advanced+25 XP

Copy your Engine/InMemory/JsonlFile/replay and LedgerService into Solution, then add: 1. static String report(LedgerService svc, java.util.List<String> keys, java.util.concurrent.Executor exec) โ€” per key, supplyAsync(() -> key + "=" + svc.get(key), exec) with orTimeout(50, MILLISECONDS) and handle โ†’ key + "=down" on failure; allOf(...).orTimeout(500, MILLISECONDS).join(); join parts in submission order, joined with ",". 2. static String prove(String seed) โ€” the proof: build a JsonlFile over a fresh temp file, record seed/a=1, seed/b=2 through a LedgerService; build an InMemory engine, record the SAME operations through another LedgerService; run report( ..., List.of("a","b"), sameExecutor) on both; return the two report strings joined with "|" โ€” they must be IDENTICAL strings for the test to pass. 3. static boolean survivesRestart(java.nio.file.Path file) โ€” engine over file, record x=9; build a SECOND service via replay(file); return whether the replayed service get("x") equals "9".

Back to lesson: Checkpoint: The Ledger, Proven