-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gno test): pass ExecContext when initializing imported packages (#…
…1965) Cherry-picked from 8fe571f (#880). <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Signed-off-by: moul <[email protected]> Co-authored-by: Morgan Bazalgette <[email protected]>
- Loading branch information
Showing
6 changed files
with
156 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
loadpkg gno.land/r/foobar/bar $WORK/bar | ||
|
||
## start a new node | ||
gnoland start | ||
|
||
# execute Render | ||
gnokey maketx call -pkgpath gno.land/r/foobar/bar -func Render -args X -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
stdout '(" orig=g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 prev=g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5" string)' | ||
stdout 'OK!' | ||
|
||
-- bar/bar.gno -- | ||
package bar | ||
|
||
import "std" | ||
|
||
var orig = std.Address("orig") | ||
var prev = std.Address("prev") | ||
|
||
func init() { | ||
orig = std.GetOrigCaller() | ||
prev = std.PrevRealm().Addr() | ||
} | ||
|
||
func Render(addr string) string { | ||
return " orig="+orig.String()+" prev="+prev.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// PKGPATH: gno.land/r/demo/tests_test | ||
package tests_test | ||
|
||
import ( | ||
"gno.land/r/demo/tests" | ||
"std" | ||
) | ||
|
||
var addr = std.Address("test") | ||
var addrInit = std.Address("addrInit") | ||
|
||
func init() { | ||
addr = std.GetOrigCaller() | ||
addrInit = tests.InitOrigCaller() | ||
} | ||
|
||
func main() { | ||
println(addr) | ||
println(addrInit) | ||
} | ||
|
||
// Output: | ||
// g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm | ||
// g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm | ||
|
||
// Realm: | ||
// switchrealm["gno.land/r/demo/tests_test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters