package host import ( "testing" "github.com/carlosframework/platform/internal/hostclaim" ) // M9: an admitted wake attempt keeps its writer only across adjacent forward // steps it has checked. Its checkpoint advances on each one; a skipped step // or a step back from the checkpoint refuses and leaves it unchanged. func TestPlan9Fix1WakeAttemptAdvancesOneCheckedStepAtATime(t *testing.T) { probing := plan9D1Session(hostclaim.PhaseLandingProbing, 11) probed := plan9D1Session(hostclaim.PhaseLandingProbed, 11) committed := plan9D1Session(hostclaim.PhaseLandingCommitted, 11) skip := &claimWakeAttempt{observed: probing} if skip.advance(committed, hostclaim.SessionContinues) { t.Fatal("probing advanced straight to committed") } if got, _ := skip.snapshot(); got.Claim.Op.Phase != hostclaim.PhaseLandingProbing { t.Fatalf("a refused step moved the checkpoint to %q", got.Claim.Op.Phase) } a := &claimWakeAttempt{observed: probing} if !a.advance(probed, hostclaim.SessionContinues) || !a.advance(committed, hostclaim.SessionContinues) { t.Fatal("checked adjacent steps ended the session") } if a.advance(probed, hostclaim.SessionContinues) || a.advance(probing, hostclaim.SessionContinues) { t.Fatal("a step back from the checkpoint kept the session") } if !a.advance(committed, hostclaim.SessionContinues) { t.Fatal("the checkpoint's own phase ended the session") } if a.advance(plan9D1Session(hostclaim.PhaseLandingCommitted, 12), hostclaim.SessionContinues) { t.Fatal("a new session kept the checkpoint") } }