render_test.gno
5.01 Kb · 109 lines
1package registry
2
3// ExampleRender pins the realm's Render output, which is its whole public
4// surface. Each example calls seedFixture first: realm globals persist for the
5// whole test binary and examples run after every Test, so without the reset the
6// pinned output would silently depend on test order.
7
8func ExampleRender() {
9 seedFixture()
10 print(Render(""))
11 // Output:
12 // # gnopm source registry
13 //
14 // Where a deployed package says it came from. Every entry is a claim made by whoever signed it, never a verified fact: this realm cannot clone a repository, so it records testimony in the shape a verifier needs and labels who said it.
15 //
16 // **Packages:** 2 · **Claims:** 3
17 //
18 // | package | claims | owner has claimed |
19 // | --- | ---: | --- |
20 // | [gno.land/p/moul/md/v1](/r/moul/gnopm/registry/v0:gno.land/p/moul/md/v1) | 1 | no |
21 // | [gno.land/r/g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh/scratch/v0](/r/moul/gnopm/registry/v0:gno.land/r/g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh/scratch/v0) | 2 | yes |
22 //
23 // [How this works](/r/moul/gnopm/registry/v0:help)
24}
25
26// The package page is the one that matters: an owner's claim and a stranger's
27// claim about the same path, under separate headings, owner first. The pinned
28// output is what stops that distinction being quietly refactored away.
29func ExampleRender_package() {
30 seedFixture()
31 print(Render(alicePkg))
32 // Output:
33 // # gno.land/r/g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh/scratch/v0
34 //
35 // 2 claim(s). A claim is what an address said, not what anyone checked.
36 //
37 // ## Claimed by the namespace owner
38 //
39 // The signer owns `g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh`, so this claim comes from the party that controls the path. That is not a proof the source matches. It is a proof of who is speaking.
40 //
41 // | field | value |
42 // | --- | --- |
43 // | claimant | `g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh` |
44 // | commit | [000000000000](https://github.com/moul/gno-contracts/tree/0000000000000000000000000000000000000000/scratch) |
45 // | repository | [https://github.com/moul/gno-contracts](https://github.com/moul/gno-contracts) |
46 // | directory | `scratch` |
47 // | ref | `refs/tags/v0.1.0` |
48 // | claimed at | block 100 |
49 // | last updated | never |
50 //
51 // ## Claimed by others
52 //
53 // These addresses do not own `g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh`. A third party may be filling in the map honestly, or pointing at a repository that has nothing to do with this package. Read the source before trusting either.
54 //
55 // | field | value |
56 // | --- | --- |
57 // | claimant | `g1vfhkyh6lta047h6lta047h6lta047h6l03vdhu` |
58 // | commit | [111111111111](https://github.com/bob/impostor/tree/1111111111111111111111111111111111111111) |
59 // | repository | [https://github.com/bob/impostor](https://github.com/bob/impostor) |
60 // | directory | `(repository root)` |
61 // | claimed at | block 110 |
62 // | last updated | never |
63 //
64 // [Back to the registry](/r/moul/gnopm/registry/v0)
65}
66
67func ExampleRender_unclaimed() {
68 seedFixture()
69 print(Render("gno.land/p/moul/nothing/v0"))
70 // Output:
71 // # gno.land/p/moul/nothing/v0
72 //
73 // Nobody has claimed a source for this package.
74 //
75 // [Claim it](/r/moul/gnopm/registry/v0$help&func=Register&pkgPath=gno.land%2Fp%2Fmoul%2Fnothing%2Fv0)
76 //
77 // [Back to the registry](/r/moul/gnopm/registry/v0)
78}
79
80func ExampleRender_help() {
81 seedFixture()
82 print(Render("help"))
83 // Output:
84 // # How this registry works
85 //
86 // A gno import path is a chain address, not a repository URL, so nothing on chain says where a deployed package came from. This realm is where an address can say so.
87 //
88 // ## What it proves
89 //
90 // Nothing on its own, and that is the honest answer. A realm cannot clone a repository, so it cannot check that the code at a commit is the code at a path. Three claims get confused with each other and only two of them can ever be settled:
91 //
92 // | claim | provable |
93 // | --- | --- |
94 // | this package came from that repository | no. Not here and not anywhere: anyone may deploy any bytes and claim any repository |
95 // | the deployed bytes equal the addpkg payload of that directory at that commit | yes, by hashing both sides. Off chain, by anything that can clone |
96 // | the claimant owns this path's namespace | yes, from chain data, and it is recomputed on every read |
97 //
98 // ## Writing to it
99 //
100 // Register the source of a package you deployed. Calling it again replaces your own claim and nobody else's, which is how you move a claim to a new commit after a redeploy.
101 //
102 // [Register](/r/moul/gnopm/registry/v0$help&func=Register) · [Withdraw](/r/moul/gnopm/registry/v0$help&func=Withdraw)
103 //
104 // Fields: the full package path, an https repository URL, a 40 or 64 character lowercase hex commit, the subdirectory holding the package (empty for the repository root), and optionally a fully-qualified ref such as `refs/tags/v1.2.0`.
105 //
106 // Anyone may claim any path. A claim from an address that does not own the namespace is not hidden: it is shown under its own heading and ranked below the owner's.
107 //
108 // [Back to the registry](/r/moul/gnopm/registry/v0)
109}