Skip to content

Neotest coverage regression #4208

@AnnaShaleva

Description

@AnnaShaleva

Current Behavior

Given the following contract.go SC:

package myctr

func MyEven(n int) bool {
	if n%2 == 0 { //nolint: gosimple
		return true
	}
	return false
}

and the following contract.yml:

name: "contract example"

and the following contract_test.go:

package myctr

import (
	"testing"

	"github.com/nspcc-dev/neo-go/pkg/neotest"
	"github.com/nspcc-dev/neo-go/pkg/neotest/chain"
)

func TestSome(t *testing.T) {
	bc, acc := chain.NewSingle(t)
	e := neotest.NewExecutor(t, bc, acc, acc)
	e.EnableCoverage(t)

	ctr := neotest.CompileFile(t, e.CommitteeHash, "./contract.go", "./contract.yml")
	e.DeployContract(t, ctr, nil)
	c := e.CommitteeInvoker(ctr.Hash)

	c.Invoke(t, true, "myEven", 0)
}

The coverage of this contract after v0.116.0 is 0%:
Image
whereas with v0.116.0 release the coverage is expected:
Image

Expected Behavior

return true branch of the given contract should be marked as covered.

Steps to Reproduce

  1. Use NeoGo v0.117.0 in go.mod.
  2. Collect coverage with:
go test -v ./... -coverprofile=coverage.txt -coverpkg=./...
go tool cover -html=coverage.txt -o coverage.html
  1. Check the result.
  2. Do the same with NeoGo v0.116.0

Regression

Yes.

Additional context

Discovered during investigation of #4207.

Metadata

Metadata

Assignees

Labels

I2Regular impactS4RoutineU2Seriously plannedbugSomething isn't workingneotestNeotest framework and coverage tool

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions