ethereum / pytest-ethereum

MIT License
19 stars 12 forks source link

Make Vyper contract compiling "lazy" #21

Open fubuloubu opened 5 years ago

fubuloubu commented 5 years ago

What was wrong?

I have a contract I am working on, so it doesn't compile yet. I don't have a test for it either, but my test suite is unable to work if this contract exists. At most, it could issue a warning about untested contracts in directory if the worry is not testing everything

How can it be fixed?

If compilation was "lazy" (aka only compiled when needed to deploy), I would avoid this problem because it would never compile contracts I don't care about.

If the problem is that you need to know what is in the manifest first, then I would suggest you allow us to specify what gets put into the manifest for testing purposes into a confest.py. This might be helpful for additional testing fixtures we may have in the local directory as well. This would make sense to me to do within stage 1 of the 2 stage deployment process:

@pytest.fixture
def contract(vy_deployer):
    # We don't need the address...
    package, _ = vy_deployer.deploy('contract')  # Deploys 'contract' from contracts/ dir
    return package.deployments.get_contract_instance('contract')  # Obtain deployed contract again?
fubuloubu commented 5 years ago

Suggestion would be:

conftest.py:

@pytest.fixture
def package(vy_deployer):
    return Package(
        'path/to/contractA.vy,
        'path/to/contractB.vy,
        ...,
        'path/to/contractZ.vy,
    )  # Compile now!

test_contractA.py:

@pytest.fixture
def contract(package):
    return package.deploy('contractA', *args)  # Wishlist: this just returns the instance!
pipermerriam commented 5 years ago

:+1: