Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
grepsuzette committed Mar 18, 2024
1 parent 6cd741e commit 9eb8476
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions examples/gno.land/r/demo/tests/z2_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ import (
"gno.land/r/demo/tests"
)

// When a single realm in the frames, PrevRealm returns the user
// When 2 or more realms in the frames, PrevRealm returns the second to last
func main() {
var (
eoa = testutils.TestAddress("someone")
rTestsAddr = std.DerivePkgAddr("gno.land/r/demo/tests")
)
std.TestSetOrigCaller(eoa)
// When a single realm in the frames, PrevRealm returns the user
if addr := tests.GetPrevRealm().Addr(); addr != eoa {
fmt.Printf("want tests.GetPrevRealm().Addr==%s, got %s\n", eoa, addr)
}
// When 2 or more realms in the frames, PrevRealm returns the second to last
if addr := tests.GetRSubtestsPrevRealm().Addr(); addr != rTestsAddr {
fmt.Printf("want GetRSubtestsPrevRealm().Addr==%s, got %s\n", rTestsAddr, addr)
}
println("tests.GetPrevRealm().Addr(): ", tests.GetPrevRealm().Addr())
println("tests.GetRSubtestsPrevRealm().Addr(): ", tests.GetRSubtestsPrevRealm().Addr())
}

// Output:
// tests.GetPrevRealm().Addr(): g1wdhk6et0dej47h6lta047h6lta047h6lrnerlk
// tests.GetRSubtestsPrevRealm().Addr(): g1gz4ycmx0s6ln2wdrsh4e00l9fsel2wskqa3snq
6 changes: 3 additions & 3 deletions examples/gno.land/r/demo/tests/z3_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func main() {
std.TestSetOrigCaller(eoa)
// Contrarily to z2_filetest.gno we EXPECT GetPrevRealms != eoa (#1704)
if addr := tests.GetPrevRealm().Addr(); addr != eoa {
fmt.Printf("want tests.GetPrevRealm().Addr==%s, got %s\n", eoa, addr)
println("want tests.GetPrevRealm().Addr ==", eoa, "got", addr)
}
// When 2 or more realms in the frames, it is also different
if addr := tests.GetRSubtestsPrevRealm().Addr(); addr != rTestsAddr {
fmt.Printf("want GetRSubtestsPrevRealm().Addr==%s, got %s\n", rTestsAddr, addr)
println("want GetRSubtestsPrevRealm().Addr ==", rTestsAddr, "got", addr)
}
}

// Output:
// want tests.GetPrevRealm().Addr==g1wdhk6et0dej47h6lta047h6lta047h6lrnerlk, got g1xufrdvnfk6zc9r0nqa23ld3tt2r5gkyvw76q63
// want tests.GetPrevRealm().Addr == g1wdhk6et0dej47h6lta047h6lta047h6lrnerlk got g1xufrdvnfk6zc9r0nqa23ld3tt2r5gkyvw76q63

0 comments on commit 9eb8476

Please sign in to comment.