Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cmd/gno): pass an ExecContext to MachineOptions in
gno run
(#2856)
This fixes: #2834 It tries to hew very closely to how the context is created under `gno test` so that there is consistency of results between code that is executed in the test and run contexts. Please let me know if there are any conventions for the codebase that I should have followed that I did not. I hooked into the portion of the `ExecRun()` that was calling `NewMachineWithOptions()`, and instead followed a similar pattern to what is defined in `test.go` to configure the machine with a context that has reasonable defaults. These, except for the Chain ID (which is `dev` when running under `gno test`), are identical to the test settings. This allows packages like `gno.land/p/demo/entropy` to work when code is executed with `gno run`, as well as any others which might try to access information only available from the context. A simple piece of code to demonstrate the issue is below. This will fail without this change. ``` package foo import ( "fmt" "std" ) func main() { fmt.Printf("GetHeight(): %d\n", std.GetHeight()) } ``` A test has been added to the tests for the run command, which tries to run code similar to the code above within the test. <details><summary>Contributors' checklist...</summary> - [X] Added new tests, or not needed, or not feasible - [X] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [X] Updated the official documentation or not needed - [X] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [X] Added references to related issues and PRs - [X] Provided any useful hints for running manual tests </details>
- Loading branch information