diff --git a/gnovm/cmd/gno/run.go b/gnovm/cmd/gno/run.go index cfbfe995a46..f174c2b4cc5 100644 --- a/gnovm/cmd/gno/run.go +++ b/gnovm/cmd/gno/run.go @@ -14,6 +14,7 @@ import ( gno "github.com/gnolang/gno/gnovm/pkg/gnolang" "github.com/gnolang/gno/gnovm/tests" "github.com/gnolang/gno/tm2/pkg/commands" + "github.com/gnolang/gno/tm2/pkg/std" ) type runCfg struct { @@ -112,11 +113,15 @@ func execRun(cfg *runCfg, args []string, io commands.IO) error { return errors.New("no files to run") } + var send std.Coins + pkgPath := string(files[0].PkgName) + ctx := tests.TestContext(pkgPath, send) m := gno.NewMachineWithOptions(gno.MachineOptions{ - PkgPath: string(files[0].PkgName), - Input: stdin, + PkgPath: pkgPath, Output: stdout, + Input: stdin, Store: testStore, + Context: ctx, Debug: cfg.debug || cfg.debugAddr != "", }) diff --git a/gnovm/cmd/gno/run_test.go b/gnovm/cmd/gno/run_test.go index 79a873cdfe5..975868b7daf 100644 --- a/gnovm/cmd/gno/run_test.go +++ b/gnovm/cmd/gno/run_test.go @@ -79,6 +79,10 @@ func TestRunApp(t *testing.T) { args: []string{"run", "../../tests/integ/invalid_assign/main.gno"}, recoverShouldContain: "cannot use bool as main.C without explicit conversion", }, + { + args: []string{"run", "-expr", "Context()", "../../tests/integ/context/context.gno"}, + stdoutShouldContain: "Context worked", + }, // TODO: a test file // TODO: args // TODO: nativeLibs VS stdlibs diff --git a/gnovm/tests/integ/context/context.gno b/gnovm/tests/integ/context/context.gno new file mode 100644 index 00000000000..92a9cc632b7 --- /dev/null +++ b/gnovm/tests/integ/context/context.gno @@ -0,0 +1,11 @@ +package runtests + +import ( + "fmt" + "std" +) + +func Context() { + // This requires a Context to work; it will fail ugly if the Context isn't available. + fmt.Printf("Context worked: %d\n", std.GetHeight()) +}