Skip to content
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

chore(gno.land): add unit tests for sdk/vm.vmHandler #2459

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

moul
Copy link
Member

@moul moul commented Jun 28, 2024

gnome$ go test -v ./sdk/vm -run TestVmHandler
=== RUN   TestVmHandlerQuery_Eval
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.Echo("hello")
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.PubString
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.ConstString
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.pvString
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.counter
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.GetCounter()
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.Inc()
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.pvEcho("hello")
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.1337
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.13.37
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.float64(1337)
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.myStructInst
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.myStructInst.Foo()
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.myStruct
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.Inc
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.fn()("hi")
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.sl
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.sl[1]
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.println(1234)
1234
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.doesnotexist
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/doesnotexist.Foo
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.Panic()
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.panic("bar")
=== RUN   TestVmHandlerQuery_Eval/gno.land/r/hello.sl[6]
--- PASS: TestVmHandlerQuery_Eval (0.03s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.Echo("hello") (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.PubString (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.ConstString (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.pvString (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.counter (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.GetCounter() (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.Inc() (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.pvEcho("hello") (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.1337 (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.13.37 (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.float64(1337) (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.myStructInst (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.myStructInst.Foo() (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.myStruct (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.Inc (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.fn()("hi") (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.sl (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.sl[1] (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.println(1234) (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.doesnotexist (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/doesnotexist.Foo (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.Panic() (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.panic("bar") (0.00s)
    --- PASS: TestVmHandlerQuery_Eval/gno.land/r/hello.sl[6] (0.00s)
=== RUN   TestVmHandlerQuery_Funcs
=== RUN   TestVmHandlerQuery_Funcs/gno.land/r/hello
=== RUN   TestVmHandlerQuery_Funcs/gno.land/r/doesnotexist
=== RUN   TestVmHandlerQuery_Funcs/std
=== RUN   TestVmHandlerQuery_Funcs/strings
--- PASS: TestVmHandlerQuery_Funcs (0.00s)
    --- PASS: TestVmHandlerQuery_Funcs/gno.land/r/hello (0.00s)
    --- PASS: TestVmHandlerQuery_Funcs/gno.land/r/doesnotexist (0.00s)
    --- PASS: TestVmHandlerQuery_Funcs/std (0.00s)
    --- PASS: TestVmHandlerQuery_Funcs/strings (0.00s)
=== RUN   TestVmHandlerQuery_File
=== RUN   TestVmHandlerQuery_File/gno.land/r/hello/hello.gno
=== RUN   TestVmHandlerQuery_File/gno.land/r/hello/README.md
=== RUN   TestVmHandlerQuery_File/gno.land/r/hello/doesnotexist.gno
=== RUN   TestVmHandlerQuery_File/gno.land/r/hello
=== RUN   TestVmHandlerQuery_File/gno.land/r/doesnotexist
=== RUN   TestVmHandlerQuery_File/gno.land/r/doesnotexist/hello.gno
--- PASS: TestVmHandlerQuery_File (0.00s)
    --- PASS: TestVmHandlerQuery_File/gno.land/r/hello/hello.gno (0.00s)
    --- PASS: TestVmHandlerQuery_File/gno.land/r/hello/README.md (0.00s)
    --- PASS: TestVmHandlerQuery_File/gno.land/r/hello/doesnotexist.gno (0.00s)
    --- PASS: TestVmHandlerQuery_File/gno.land/r/hello (0.00s)
    --- PASS: TestVmHandlerQuery_File/gno.land/r/doesnotexist (0.00s)
    --- PASS: TestVmHandlerQuery_File/gno.land/r/doesnotexist/hello.gno (0.00s)
PASS
ok  	github.com/gnolang/gno/gno.land/pkg/sdk/vm	(cached)

@moul moul self-assigned this Jun 28, 2024
@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Jun 28, 2024
@moul moul changed the title dev/moul/vmhandler test chore: add unit tests for vmHandler Jun 28, 2024
Signed-off-by: moul <[email protected]>
@moul moul marked this pull request as ready for review June 28, 2024 18:04
moul added 2 commits June 28, 2024 20:46
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
@moul moul changed the title chore: add unit tests for vmHandler chore(gno.land): add unit tests for sdk/vm.vmHandler Jun 28, 2024
Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.13%. Comparing base (9897b66) to head (6c935a8).
Report is 28 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2459      +/-   ##
==========================================
+ Coverage   60.87%   61.13%   +0.26%     
==========================================
  Files         563      564       +1     
  Lines       75193    76624    +1431     
==========================================
+ Hits        45770    46845    +1075     
- Misses      26055    26315     +260     
- Partials     3368     3464      +96     
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (ø)
contribs/gnofaucet 15.31% <ø> (ø)
gno.land 71.02% <ø> (+3.84%) ⬆️
gnovm 65.77% <ø> (+0.13%) ⬆️
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (-0.36%) ⬇️
tm2 62.08% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thehowl
Copy link
Member

thehowl commented Sep 23, 2024

ci is failing. didn't you fix this yesterday?

output := fmt.Sprintf("%v", r)
assert.Regexp(t, tc.expectedPanicMatch, output)
} else {
assert.Equal(t, "", tc.expectedPanicMatch, "should not panic")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here should be:

assert.Equal(t, tc.expectedPanicMatch, "", "should not panic")

right?

}
}()
res := vmHandler.Query(env.ctx, req)
if tc.expectedErrorMatch == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here should be something like:

if tc.expectedPanicMatch == "" {
    if tc.expectedErrorMatch == "" {
        .......
    }
}

to ensure these two tests are isolated.

Signed-off-by: moul <[email protected]>
@moul
Copy link
Member Author

moul commented Oct 3, 2024

should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related
Projects
Status: No status
Status: 🙏🏻 Awaiting peer review
Status: Agenda
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants