-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cmd/gno): pass an ExecContext to MachineOptions in gno run
#2856
Conversation
This addresses this issue: gnolang#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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2856 +/- ##
==========================================
+ Coverage 60.92% 60.95% +0.02%
==========================================
Files 564 564
Lines 75267 75380 +113
==========================================
+ Hits 45854 45945 +91
- Misses 26041 26049 +8
- Partials 3372 3386 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
gno run
.gno run
.
gno run
.gno run
@@ -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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to have the height so we can detect if it changes.
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 callingNewMachineWithOptions()
, and instead followed a similar pattern to what is defined intest.go
to configure the machine with a context that has reasonable defaults. These, except for the Chain ID (which isdev
when running undergno test
), are identical to the test settings.This allows packages like
gno.land/p/demo/entropy
to work when code is executed withgno 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.
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.
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description