Write the claim as a source test. Any .tri program under a _test/ folder is a test, and its leading structured comment declares named data cases. Each case is one call to main, and only a true result passes.
#{
u16 schemaVersion = 1
chest[] cases = [
{ text name = "link-up", chest arguments = { u64 applied = 40, u64 saved = 0 } },
{ text name = "drop-90s", chest arguments = { u64 applied = 40, u64 saved = 18 } },
{ text name = "drop-90s-late-ack", chest arguments = { u64 applied = 47, u64 saved = 18 } }
]
}
# One saved edit every 5 s: a 90-second drop holds 18 edits, 41 to 58.
# After reconnect the tablet must still hold exactly the edits the server
# has not applied, in the order the crew saved them.
bool main(u64 applied, u64 saved) {
u64[] held = []
repeat (saved, u64 i = 1) {
held.add(40 + i)
}
u64[] pending = a.queue.unsent(applied, held)
u64 last = 40 + saved
u64 expected = 0
if (last > applied) { expected = last - applied }
assert (u64(pending.count()) == expected, "no edit lost, none sent twice")
u64 next = applied + 1
foreach (seq in pending) {
assert (seq == next, "sent in the order the crew saved")
next = next + 1
}
return true
}