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

[GnoVM] Panics in tests do not revert state #2043

Open
leohhhn opened this issue May 6, 2024 · 0 comments
Open

[GnoVM] Panics in tests do not revert state #2043

leohhhn opened this issue May 6, 2024 · 0 comments

Comments

@leohhhn
Copy link
Contributor

leohhhn commented May 6, 2024

Description

Check this out:

package panic

var count int

func Increment(shouldRevert bool) {
	count++

	if shouldRevert {
		count++
		panic("i was instructed to revert!")
	}
}
package panic

import "testing"

func TestIncrement(t *testing.T) {
	println(count)
	Increment(true)
}

func TestIncrement2(t *testing.T) {
	println(count)
}

Running gno test will output the following:

❯ gno test . -v
--- WARNING: unable to read package path from gno.mod or gno root directory; try creating a gno.mod file
=== RUN   TestIncrement
0
panic: i was instructed to revert!
--- FAIL: TestIncrement (0.00s)
=== RUN   TestIncrement2
2
--- PASS: TestIncrement2 (0.00s)
.: test pkg: failed: "TestIncrement"
FAIL
FAIL    .       0.69s
FAIL
FAIL
FAIL: 0 build errors, 1 test errors

Issue number one is this, where the machine state & context is not reset between tests, and the second problem is, as demonstrated with this issue, the fact that a panic statement does not revert the state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

3 participants