ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
892 stars 131 forks source link

Coverage report is not consistent #1964

Open pandadefi opened 8 months ago

pandadefi commented 8 months ago

Environment information

$ ape --version
0.7.11

$ ape plugins list
  etherscan    0.7.2
  foundry      0.7.4
  vyper        0.7.0
$ cat ape-config.yaml

name: XXX
plugins:
  - name: vyper
  - name: foundry
  - name: etherscan
ethereum:
  default_network: mainnet-fork
  mainnet_fork:
    default_provider: foundry
geth:
  ethereum:
    mainnet:
      uri: http://localhost:8540

test:
  coverage:
    reports:
      terminal: False 
      xml: True
      html: True

What went wrong?

Please include information like:

When running ape test --coverage the coverage report displayed several inconsistencies. Some lines that were sandwiched between two lines that were covered were not. After looking at the XML file some more inconsistencies were found. The two lines above and beyond the not-covered one displayed a different number of hits.

            <line number="155" hits="8"/>
            <line number="156" hits="0"/>
            <line number="157" hits="2"/>
Screenshot 2024-03-14 at 13 11 24

I have also noticed that some of the natspec code is considered part of the code that needs tests and will appear in the XML report with zero hits.

Screenshot 2024-03-14 at 13 35 50

While I was looking at the XML report, I made a small tool to compile the XML into a more readable HTML file that might help you while fixing this issue, it can be found here

The node used to test was a neithermind node.

linear[bot] commented 8 months ago

APE-1710 Coverage report is not consistent

fubuloubu commented 8 months ago

I'm curious if there's no hits because there's no branch logic in that statement

antazoey commented 3 months ago

What repo is this?

pandadefi commented 3 months ago

What repo is this?

https://github.com/1uptokyo/1upyfi