diff --git a/contracts/seats/mesh-wants/seat.json b/contracts/seats/mesh-wants/seat.json index f149808c..e0564718 100644 --- a/contracts/seats/mesh-wants/seat.json +++ b/contracts/seats/mesh-wants/seat.json @@ -305,7 +305,8 @@ "name": "wanted", "subject": "wanted..", "keep": { - "last-per-subject": true + "last-per-subject": true, + "max-age-days": 0 }, "body": { "type": "object", diff --git a/modules/mesh-grants/internal/grants/wantedkeep_test.go b/modules/mesh-grants/internal/grants/wantedkeep_test.go new file mode 100644 index 00000000..e8356bbe --- /dev/null +++ b/modules/mesh-grants/internal/grants/wantedkeep_test.go @@ -0,0 +1,32 @@ +package grants + +import ( + "os" + "path/filepath" + "testing" + + "git.novox.be/novox/mesh-sdk/go/seatdef" +) + +// Design 47 G A-114 (ยง693, A-61): the seat mesh-wants' `wanted` stream keeps the last message of each subject with no age +// limit, so each want's last word is read whole at a start. +func TestWantedKeepsEachWantsLastWordWithNoAgeLimit(t *testing.T) { + raw, err := os.ReadFile(filepath.Join("..", "..", "..", "..", "contracts", "seats", "mesh-wants", "seat.json")) + if err != nil { + t.Fatal(err) + } + d, err := seatdef.Parse(raw) + if err != nil { + t.Fatal(err) + } + for _, e := range d.Events { + if e.Name != "wanted" { + continue + } + if !e.KeptLastPerSubject() || e.KeptAgeDays() != 0 { + t.Errorf("wanted keeps last-per-subject %v for %d days, want true and 0 (no age limit)", e.KeptLastPerSubject(), e.KeptAgeDays()) + } + return + } + t.Fatal("the seat mesh-wants has no event wanted") +}