Skip to content

Code Coverage isn't working with Brownie and this version of the Vyper Compiler #1

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

Open
scherrey opened this issue Mar 22, 2022 · 1 comment

Comments

@scherrey
Copy link
Contributor

  1. Make a Python virtual environment with Python 3.9.x
  2. Check out this repo.
  3. make init (Note that it is installing a Vyper 3.0.2beta branch with some fixes for immutable bugs.)
  4. make test
  5. Note that although the ERC20 and SurpriseBox721 tests all execute and pass, the test runner claims there was zero code coverage for the ERC20 contract and pretends the SurpriseBox721 doesn't even exist.

Really need code coverage to work on the SurpriseBox721 contract if we're ever going to feel safe using it on Main Net.
(It is a work in progress still but is sufficiently functional for these test cases.)

``(VyperDemoContracts) scherrey@pixies:~/projects/VyperDemoContracts
$ make test
brownie test --coverage -v
Brownie v1.17.2 - Python development framework for Ethereum

Compiling contracts...
Vyper version: 0.3.1+commit.0f9ff286
Generating build data...

  • ERC1155
  • ERC20
  • ERC721
  • SurpriseBox721

==================================================== test session starts ====================================================
platform linux -- Python 3.9.2, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/scherrey/.virtualenvs/VyperDemoContracts/bin/python
cachedir: .pytest_cache
hypothesis profile 'brownie-verbose' -> verbosity=2, deadline=None, max_examples=50, stateful_step_count=10, report_multiple_bugs=False, database=DirectoryBasedExampleDatabase(PosixPath('/home/scherrey/.brownie/hypothesis'))
rootdir: /home/scherrey/projects/VyperDemoContracts
plugins: eth-brownie-1.17.2, hypothesis-6.27.3, forked-1.3.0, bdd-5.0.0, asyncio-0.18.1, xdist-1.34.0, web3-5.25.0
asyncio: mode=legacy
collected 45 items

Launching 'ganache-cli --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...

tests/test_ERC1155.py::test_run PASSED [ 2%]
tests/test_ERC1155.py::test_mintNft PASSED [ 4%]
tests/test_ERC1155.py::test_mintTokens PASSED [ 6%]
tests/test_ERC1155.py::test_safeTransferFrom PASSED [ 8%]
tests/test_ERC1155.py::test_safeTransferFromReverts PASSED [ 11%]
tests/test_ERC1155.py::test_balanceOf PASSED [ 13%]
tests/test_ERC1155.py::test_balanceOfReverts PASSED [ 15%]
tests/test_ERC1155.py::test_AddContract_event PASSED [ 17%]
tests/test_ERC1155.py::test_setApproveAmount_event PASSED [ 20%]
tests/test_ERC1155.py::test_setBaseURI PASSED [ 22%]
tests/test_ERC1155.py::test_name PASSED [ 24%]
tests/test_ERC1155.py::test_symbol PASSED [ 26%]
tests/test_ERC1155.py::test_totalSupply PASSED [ 28%]
tests/test_ERC1155.py::test_destruct PASSED [ 31%]
tests/test_ERC20.py::test_simple_transfer PASSED [ 33%]
tests/test_ERC20.py::test_destruct PASSED [ 35%]
tests/test_ERC20.py::test_mint_and_burn PASSED [ 37%]
tests/test_ERC20.py::test_totalSupply PASSED [ 40%]
tests/test_ERC20.py::test_transfer PASSED [ 42%]
tests/test_ERC20.py::test_transferFrom_and_Allowance PASSED [ 44%]
tests/test_ERC20.py::test_burnFrom_and_Allowance PASSED [ 46%]
tests/test_ERC721.py::test_supportsInterface PASSED [ 48%]
tests/test_ERC721.py::test_balanceOf PASSED [ 51%]
tests/test_ERC721.py::test_ownerOf PASSED [ 53%]
tests/test_ERC721.py::test_getApproved PASSED [ 55%]
tests/test_ERC721.py::test_isApprovedForAll PASSED [ 57%]
tests/test_ERC721.py::test_transferFrom_by_owner PASSED [ 60%]
tests/test_ERC721.py::test_transferFrom_by_approved PASSED [ 62%]
tests/test_ERC721.py::test_transferFrom_by_operator PASSED [ 64%]
tests/test_ERC721.py::test_safeTransferFrom_by_owner PASSED [ 66%]
tests/test_ERC721.py::test_safeTransferFrom_by_approved PASSED [ 68%]
tests/test_ERC721.py::test_safeTransferFrom_by_operator PASSED [ 71%]
tests/test_ERC721.py::test_destruct PASSED [ 73%]
tests/test_SurpriseBox721.py::test_supportsInterface PASSED [ 75%]
tests/test_SurpriseBox721.py::test_balanceOf PASSED [ 77%]
tests/test_SurpriseBox721.py::test_ownerOf PASSED [ 80%]
tests/test_SurpriseBox721.py::test_getApproved PASSED [ 82%]
tests/test_SurpriseBox721.py::test_isApprovedForAll PASSED [ 84%]
tests/test_SurpriseBox721.py::test_transferFrom_by_owner PASSED [ 86%]
tests/test_SurpriseBox721.py::test_transferFrom_by_approved PASSED [ 88%]
tests/test_SurpriseBox721.py::test_transferFrom_by_operator PASSED [ 91%]
tests/test_SurpriseBox721.py::test_safeTransferFrom_by_owner PASSED [ 93%]
tests/test_SurpriseBox721.py::test_safeTransferFrom_by_approved PASSED [ 95%]
tests/test_SurpriseBox721.py::test_safeTransferFrom_by_operator PASSED [ 97%]
tests/test_SurpriseBox721.py::test_destruct PASSED [100%]

===================================================== warnings summary ======================================================
../../.virtualenvs/VyperDemoContracts/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
/home/scherrey/.virtualenvs/VyperDemoContracts/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

tests/test_ERC1155.py:1
/home/scherrey/projects/VyperDemoContracts/tests/test_ERC1155.py:1: PendingDeprecationWarning: lib2to3 package is deprecated and may not be able to parse Python 3.10+
from lib2to3.pgen2 import token

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================= Coverage ==========================================================

contract: ERC1155 - 66.2%
ERC1155.balanceOf - 87.5%
ERC1155.name - 87.5%
ERC1155.symbol - 87.5%
ERC1155.totalSupply - 87.5%
ERC1155.addERC20Contract - 75.0%
ERC1155.addERC721Contract - 75.0%
ERC1155.mintNFT - 75.0%
ERC1155.mintToken - 75.0%
ERC1155.self_destruct - 75.0%
ERC1155.setApproveAmount - 75.0%
ERC1155.setBaseURI - 75.0%
ERC1155.uri - 75.0%
ERC1155.safeTransferFrom - 68.8%
ERC1155.default - 0.0%
ERC1155._doSafeBatchTransferAcceptanceCheck - 0.0%
ERC1155._doSafeTransferAcceptanceCheck - 0.0%

contract: ERC20 - 0.0%

contract: ERC721 - 80.4%
ERC721._clearApproval - 100.0%
ERC721._uint_to_string - 85.4%
ERC721.approve - 75.0%
ERC721.safeTransferFrom - 41.7%

Coverage report saved at /home/scherrey/projects/VyperDemoContracts/reports/coverage.json
View the report using the Brownie GUI
======================================== 45 passed, 2 warnings in 140.13s (0:02:20) =========================================
Terminating local RPC client...
(VyperDemoContracts) scherrey@pixies:~/projects/VyperDemoContracts
$ ``

@scherrey
Copy link
Contributor Author

Note : Please use node version v16.13.1. More recent versions of node will give an error when executing ganach-cli.

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

No branches or pull requests

1 participant