neo-go icon indicating copy to clipboard operation
neo-go copied to clipboard

Make neotest coverage properly handle contract update

Open AnnaShaleva opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

Contract update often implies new source file and new instructions offsets. Currently neotest internally treats an updated contract as a new one (since it has a new sourcepath), and it's correct: https://github.com/nspcc-dev/neo-go/blob/7766168c19ac885da64696f0de41afd28f3c53fe/pkg/neotest/compile.go#L24-L25

However, coverage tool identifies contracts by hash: https://github.com/nspcc-dev/neo-go/blob/3e31b118c5159a91634795bb7fad4b5eb9f45652/pkg/neotest/coverage.go#L29-L30 Hence, coverage tool can't really distinguish old executable from the new one since both of them have the same hash. It leads to the fact that coverage results of updated and old contracts are mixed (and even may be invalid due to instructions offset update).

Describe the solution you'd like

I thought about making coverage tool distinguish contracts coverage by source path, exactly like neotest does. The trick is VM execution hook doesn't have access to the executable contract source, VM can only access executable script hash. This problem my be solved by accessing contract's path via Executor state provided to VM execution hook.

Describe alternatives you've considered

No other alternatives yet, but there should be any.

AnnaShaleva avatar Aug 19 '24 10:08 AnnaShaleva