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

neotest: don't collect coverage for contracts with empty DI #3600

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

AnnaShaleva
Copy link
Member

Users are allowed to provide any contract to neotest, including those contracts that don't have DebugInfo filled in. Neotest should filter them out, otherwise panic may occur on attempt to write coverage profile:

--- FAIL: TestDeploys (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference
	panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xc6f5b5]

goroutine 1735 [running]:
testing.tRunner.func1.2({0xd7aa80, 0x1723f60})
	/usr/local/go/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1634 +0x377
panic({0xd7aa80?, 0x1723f60?})
	/usr/local/go/src/runtime/panic.go:770 +0x132
github.com/nspcc-dev/neo-go/pkg/neotest.processCover()
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:143 +0xd5
github.com/nspcc-dev/neo-go/pkg/neotest.writeCoverageReport({0x10c6260, 0xc00033a378})
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:123 +0x4b
github.com/nspcc-dev/neo-go/pkg/neotest.reportCoverage({0x10db278, 0xc00021a000})
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:118 +0x165
github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).trackCoverage.func1()
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/basic.go:182 +0x1b
testing.(*common).Cleanup.func1()
	/usr/local/go/src/testing/testing.go:1175 +0x10f
testing.(*common).runCleanup(0xc00021a000, 0x58d7c0?)
	/usr/local/go/src/testing/testing.go:1353 +0xdb
testing.(*common).runCleanup.func2()
	/usr/local/go/src/testing/testing.go:1337 +0x47
panic({0xd7aa80?, 0x1723f60?})

An example of such partially-filled contract is:
https://github.com/nspcc-dev/neofs-contract/blob/a8d5e001a2e5a552676eecd40ef78629ecdfafa2/tests/deploys_test.go#L13 https://github.com/nspcc-dev/neofs-contract/blob/a8d5e001a2e5a552676eecd40ef78629ecdfafa2/contracts/contracts.go#L96

Users are allowed to provide any contract to neotest, including those
contracts that don't have DebugInfo filled in. Neotest should filter
them out, otherwise panic may occur on attempt to write coverage profile:
```
--- FAIL: TestDeploys (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference
	panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xc6f5b5]

goroutine 1735 [running]:
testing.tRunner.func1.2({0xd7aa80, 0x1723f60})
	/usr/local/go/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1634 +0x377
panic({0xd7aa80?, 0x1723f60?})
	/usr/local/go/src/runtime/panic.go:770 +0x132
github.com/nspcc-dev/neo-go/pkg/neotest.processCover()
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:143 +0xd5
github.com/nspcc-dev/neo-go/pkg/neotest.writeCoverageReport({0x10c6260, 0xc00033a378})
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:123 +0x4b
github.com/nspcc-dev/neo-go/pkg/neotest.reportCoverage({0x10db278, 0xc00021a000})
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:118 +0x165
github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).trackCoverage.func1()
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/basic.go:182 +0x1b
testing.(*common).Cleanup.func1()
	/usr/local/go/src/testing/testing.go:1175 +0x10f
testing.(*common).runCleanup(0xc00021a000, 0x58d7c0?)
	/usr/local/go/src/testing/testing.go:1353 +0xdb
testing.(*common).runCleanup.func2()
	/usr/local/go/src/testing/testing.go:1337 +0x47
panic({0xd7aa80?, 0x1723f60?})
```

An example of such partially-filled contract is:
https://github.com/nspcc-dev/neofs-contract/blob/a8d5e001a2e5a552676eecd40ef78629ecdfafa2/tests/deploys_test.go#L13
https://github.com/nspcc-dev/neofs-contract/blob/a8d5e001a2e5a552676eecd40ef78629ecdfafa2/contracts/contracts.go#L96

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
@AnnaShaleva AnnaShaleva added bug Something isn't working neotest Neotest framework and coverage tool labels Oct 7, 2024
@AnnaShaleva AnnaShaleva added this to the v0.106.4 milestone Oct 7, 2024
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.20%. Comparing base (1115193) to head (7fac3bc).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/neotest/coverage.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3600      +/-   ##
==========================================
- Coverage   85.25%   85.20%   -0.06%     
==========================================
  Files         333      333              
  Lines       39007    39009       +2     
==========================================
- Hits        33256    33238      -18     
- Misses       4179     4205      +26     
+ Partials     1572     1566       -6     

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

@roman-khimov roman-khimov merged commit 0968c3a into master Oct 7, 2024
18 of 20 checks passed
@roman-khimov roman-khimov deleted the fix-cover-panic branch October 7, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working neotest Neotest framework and coverage tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants