z_0_filetest.gno
1.09 Kb ยท 46 lines
1// PKGPATH: gno.land/r/test/test
2package test
3
4import (
5 "std"
6
7 "gno.land/r/n2p5/loci"
8)
9
10func main(cur realm) {
11 caller := std.CurrentRealm()
12 println("caller: " + string(caller.Address()))
13
14 // test nothing being set, yet.
15 r0 := loci.Get(cross, caller.Address())
16 println("expect: " + "")
17 println("got : " + r0)
18
19 // set the value, which uses the CurrentRealm as the caller.
20 input1 := "aGVsbG8sIHdvcmxkCg=="
21 loci.Set(cross, input1)
22 println("set : " + string(input1))
23 r1 := loci.Get(cross, caller.Address())
24 println("expect: " + input1)
25 println("got : " + r1)
26
27 // change the value, which should override the previous value.
28 input2 := "Z29vZGJ5ZSwgd29ybGQK"
29 loci.Set(cross, input2)
30 println("set : " + string(input2))
31 r2 := loci.Get(cross, caller.Address())
32 println("expect: " + input2)
33 println("got : " + r2)
34
35}
36
37// Output:
38// caller: g1z7fga7u94pdmamlvcrtvsfwxgsye0qv3rres7n
39// expect:
40// got :
41// set : aGVsbG8sIHdvcmxkCg==
42// expect: aGVsbG8sIHdvcmxkCg==
43// got : aGVsbG8sIHdvcmxkCg==
44// set : Z29vZGJ5ZSwgd29ybGQK
45// expect: Z29vZGJ5ZSwgd29ybGQK
46// got : Z29vZGJ5ZSwgd29ybGQK