Make Complete atomic and guard zero deadline

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 11:49:03 -04:00
parent 18108c3da3
commit a8216095de
2 changed files with 33 additions and 6 deletions
+20
View File
@@ -85,3 +85,23 @@ func TestStateRestoresFromSnapshot(t *testing.T) {
t.Fatalf("restored commitment missing: %+v", st.Commitment)
}
}
func TestRestoredCommitmentKeepsDeadline(t *testing.T) {
path := filepath.Join(t.TempDir(), "state.json")
first, err := New(path)
if err != nil {
t.Fatalf("new: %v", err)
}
_ = first.EnterPlanning()
_ = first.StartManualCommitment("Keep deadline", "done", 25*time.Minute)
want := first.State().Commitment.DeadlineUnixSecs
second, err := New(path)
if err != nil {
t.Fatalf("reopen: %v", err)
}
got := second.State().Commitment
if got == nil || got.DeadlineUnixSecs != want {
t.Fatalf("restored deadline: got %+v want %d", got, want)
}
}