Skip to content

Commit

Permalink
unittest Assert/IsOriginCall
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Mar 5, 2023
1 parent f03123a commit f4d832e
Show file tree
Hide file tree
Showing 35 changed files with 153 additions and 6 deletions.
12 changes: 12 additions & 0 deletions examples/gno.land/p/demo/testutils/misc.gno
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
package testutils

import "testing"

// For testing std.GetCallerAt().
func WrapCall(fn func()) {
fn()
}

func RequirePanic(t *testing.T, f func(), expRecover string) {
defer func() {
r := recover()
if r == nil || r.(string) != expRecover {
t.Fatalf("expected panic with '%v', got '%v'", expRecover, r)
}
}()
f()
}
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/boards/z_0_a_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
package boards_test

import (
"std"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
)

var bid boards.BoardID

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
bid = boards.CreateBoard("test_board")
boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)")
pid := boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)")
Expand Down
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/boards/z_0_b_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ package boards_test
// SEND: 199000000ugnot

import (
"std"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)

var bid boards.BoardID

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")
bid = boards.CreateBoard("test_board")
}
Expand Down
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/boards/z_0_c_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)

var bid boards.BoardID

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")
boards.CreateThread(1, "First Post (title)", "Body of the first post. (body)")
}
Expand Down
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/boards/z_0_d_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)

var bid boards.BoardID

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")
bid = boards.CreateBoard("test_board")
boards.CreateReply(bid, 0, 0, "Reply of the second post")
Expand Down
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/boards/z_0_e_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)

var bid boards.BoardID

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")
boards.CreateReply(bid, 0, 0, "Reply of the second post")
}
Expand Down
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/boards/z_0_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)

var bid boards.BoardID

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_10_a_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_10_b_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 2000000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_10_c_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -17,6 +19,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_10_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_11_a_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 2000000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_11_b_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 2000000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_11_c_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 2000000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_11_d_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 2000000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -17,6 +19,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_11_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 2000000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
4 changes: 4 additions & 0 deletions examples/gno.land/r/demo/boards/z_1_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)

var board *boards.Board

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

_ = boards.CreateBoard("test_board_1")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_2_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/boards/z_3_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down
9 changes: 6 additions & 3 deletions examples/gno.land/r/demo/boards/z_4_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package boards_test
// SEND: 200000000ugnot

import (
"std"
"strconv"

"gno.land/p/demo/testutils"
"gno.land/r/demo/boards"
"gno.land/r/demo/users"
)
Expand All @@ -16,6 +18,7 @@ var (
)

func init() {
std.TestSetOrigCaller(testutils.TestAddress("test"))
users.Register("", "gnouser", "my profile")

bid = boards.CreateBoard("test_board")
Expand Down Expand Up @@ -458,7 +461,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.StringValue",
// "value": "g1arjyc64rpthwn8zhxtzjvearm5scy43y7vm985"
// "value": "g1w3jhxazlta047h6lta047h6lta047h6lwmjv0n"
// }
// },
// {
Expand Down Expand Up @@ -837,7 +840,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.StringValue",
// "value": "g1arjyc64rpthwn8zhxtzjvearm5scy43y7vm985"
// "value": "g1w3jhxazlta047h6lta047h6lta047h6lwmjv0n"
// }
// },
// {
Expand All @@ -847,7 +850,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "04bcdca23188f0e1b9a57b36c4bb33ed3cd72446",
// "Hash": "205f2a839a0ec5a5fb335cacca1cf87b1c2f5268",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:82"
// }
// },
Expand Down
Loading

0 comments on commit f4d832e

Please sign in to comment.