1package gnomem23import (4 "testing"56 "gno.land/p/nt/testutils/v0"7 "gno.land/p/nt/uassert/v0"8)910var (11 researcher = testutils.TestAddress("researcher")12 skeptic = testutils.TestAddress("skeptic")13 judge = testutils.TestAddress("judge")14)1516// The canonical scenario from the design: a researcher proposes, a skeptic17// contests with an exploit, an adjudicator supersedes with the corrected18// claim.19func TestContestedThenSuperseded(cur realm, t *testing.T) {20 testing.SetRealm(testing.NewUserRealm(researcher))21 id := ProposeClaim(cross(cur), "foo/v2", "is", "safe to deploy", "report#H1", 82)22 uassert.Equal(t, uint64(1), id)23 uassert.Equal(t, string(StatusProposed), string(Get(id).Status))2425 // Skeptic contests with a refutation.26 testing.SetRealm(testing.NewUserRealm(skeptic))27 ContestClaim(cross(cur), id, "unbounded allocation", "exploit#H2")28 uassert.Equal(t, string(StatusContested), string(Get(id).Status))29 uassert.True(t, IsOpen(id))3031 // Adjudicator supersedes with the corrected claim.32 testing.SetRealm(testing.NewUserRealm(judge))33 newID := SupersedeClaim(cross(cur), id, "foo/v2", "is", "unsafe before commit abc123", "report#H3", 95)34 uassert.Equal(t, uint64(2), newID)3536 old := Get(id)37 uassert.Equal(t, string(StatusSuperseded), string(old.Status))38 uassert.Equal(t, newID, old.SupersededBy)39 uassert.False(t, IsOpen(id)) // superseded is terminal4041 newC := Get(newID)42 uassert.Equal(t, id, newC.Supersedes)43 uassert.Equal(t, 1, len(newC.Evidence)) // the initial report#H34445 uassert.True(t, len(Render("")) > 0)46 uassert.True(t, len(Render("1")) > 0)47 uassert.True(t, len(Render("2")) > 0)48}4950func TestSupportThenAccept(cur realm, t *testing.T) {51 testing.SetRealm(testing.NewUserRealm(researcher))52 id := ProposeClaim(cross(cur), "gnovm", "supports", "persistent object graphs", "", 90)5354 testing.SetRealm(testing.NewUserRealm(skeptic))55 SupportClaim(cross(cur), id, 88, "confirmed in docs")56 uassert.Equal(t, string(StatusSupported), string(Get(id).Status))5758 testing.SetRealm(testing.NewUserRealm(judge))59 ResolveClaim(cross(cur), id, true)60 uassert.Equal(t, string(StatusAccepted), string(Get(id).Status))61 uassert.False(t, IsOpen(id))62}6364func TestCannotMutateTerminal(cur realm, t *testing.T) {65 testing.SetRealm(testing.NewUserRealm(researcher))66 id := ProposeClaim(cross(cur), "x", "is", "y", "", 50)67 ResolveClaim(cross(cur), id, false) // retracted, terminal6869 uassert.AbortsWithMessage(t, cur, "claim is resolved (terminal): retracted", func(cur realm) {70 SupportClaim(cur, id, 10, "too late")71 })72}7374func TestBadInputs(cur realm, t *testing.T) {75 testing.SetRealm(testing.NewUserRealm(researcher))76 uassert.AbortsWithMessage(t, cur, "empty triple field", func(cur realm) {77 ProposeClaim(cur, "", "is", "y", "", 10)78 })79 uassert.AbortsWithMessage(t, cur, "confidence must be 0..100", func(cur realm) {80 ProposeClaim(cur, "a", "b", "c", "", 200)81 })82}83AddEvidence(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, id uint64, kind string, hash string)
ContestClaim(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, id uint64, note string, evidenceHash string)
Count() int
Get(id uint64) struct{ID uint64; Subject string; Predicate string; Object string; Author .uverse.address; Confidence uint8; Status gno.land/r/moul/agents/gnomem/v0.Status; CreatedAt int64; Supports []gno.land/r/moul/agents/gnomem/v0.Endorsement; Contests []gno.land/r/moul/agents/gnomem/v0.Endorsement; Evidence []gno.land/r/moul/agents/gnomem/v0.Evidence; SupersededBy uint64; Supersedes uint64; Resolver .uverse.address; ResolvedAt int64}
IsOpen(id uint64) bool
ProposeClaim(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, subject string, predicate string, object string, evidenceHash string, confidence uint8) uint64
Render(path string) string
ResolveClaim(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, id uint64, accepted bool)
SupersedeClaim(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, oldID uint64, subject string, predicate string, object string, evidenceHash string, confidence uint8) uint64
SupportClaim(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, id uint64, confidence uint8, note string)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.