z_12_a_filetest.gno
0.96 Kb ยท 34 lines
1// PKGPATH: gno.land/r/demo/boards_test
2package boards_test
3
4// SEND: 1000000ugnot
5
6import (
7 "std"
8 "testing"
9
10 "gno.land/p/demo/testutils"
11 "gno.land/r/demo/boards"
12 users "gno.land/r/gnoland/users/v1"
13)
14
15func main() {
16 testing.SetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller
17 users.Register("gnouser123")
18 // create a post via registered user
19 bid1 := boards.CreateBoard("test_board1")
20 pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)")
21 bid2 := boards.CreateBoard("test_board2")
22
23 // create a repost via anon user
24 test2 := testutils.TestAddress("test2")
25 testing.SetOriginCaller(test2)
26 testing.SetOriginSend(std.Coins{{"ugnot", 9000000}})
27
28 rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2)
29 println(rid)
30 println(boards.Render("test_board1"))
31}
32
33// Error:
34// please register, otherwise minimum fee 100000000 is required if anonymous