OpenZeppelin Test Environment – Roadmap Q2 2020

OpenZeppelin Test Environment is a blazing fast test library for smart contracts. We use it internally at OpenZeppelin and managed to drop our Contracts tests suite CI time from 21 minutes to 12 minutes and bootstrap time from 50 seconds to 5 seconds .

We are happy to announce we are looking to expand its feature set. After careful examination of the community’s feedback and brainstorming new ideas we are pleased to present the new planned features.

Solidity Coverage

Test suites and code coverage are the bread and butter of smart contracts testing. Solidity Coverage is a well-established library for code coverage in smart contracts tests, but it is certainly a missing link in developer experience provided by Test Environment. After multiple requests by the community, we are proposing to add support for it to Test Environment. If you are tracking coverage of your contracts, let us know in this thread!

Ganache Fork

With DeFi protocols being on fire there is more and more need to test code in integration as opposed to testing in isolation. Unfortunately, recreating a mainnet environment locally can prove to be difficult. Nevertheless, Ganache provides an option to fork a chain and use it for test purposes. This approach allows running tests on other protocols such as Maker, Compound, and Uniswap without complicated local test setups. Yet another reason to test on mainnet is to make sure your upgrade process goes swiftly.

At the moment Test Environment has barebones configuration when it comes to running Ganache. We are looking at supporting the fork option as well as some other options, so you can easily run your test suite on a mainnet fork if needed.

Finally

We are committed to providing the best developer experience. If you want to see these features implemented, please let us know your use case and how you are handling this currently, so we can build a solution that caters for your needs!

If you want to learn more about Test Environment, check out the GitHub page and follow our progress.

5 Likes

Tagging @jamesmorgan, @miohtama, @amateur-dev, @msolomon4, @gitpusha (amongst others in the community) who have asked about OpenZeppelin Test Environment and solidity coverage or testing with ganache-fork.

Would appreciate knowing from the community if you want these features, your use case and how you are handling this currently.

3 Likes

@abcoathup Andy Gray from BlockRocket here - +1 for solidity coverage.

Time is always the next tricky things. Being able to keep the blocks and timestamp in sync and moving to a moment in the future consistently.

We also use gas estimations a lot with balances - guess these two are more for test-helpers though.

We use a couple of scripts locally, 1 to run in with compile, 1 without compile for speed. Might want to document this approach?

Anyhow - good luck and godspeed!

2 Likes

Adding support for Solidity Coverage is a great idea.

In regards to ganache forking, I’d love to see full support for all the configuration options it offers. My main use case for this is simply building on top of existing mainnet contracts, and using the unlock flag to initialize accounts with ERC20 tokens, etc. This does require me to also use the networkId flag, because otherwise the OpenZeppelin CLI will think the local ganache chain is the mainnet (since the chain ID would be 1 by default) and overwrite mainnet.json as a result.

Right now I work around this by using Truffle for testing, because that of course lets you test against a ganache instance configured however you’d like. Adding support for this into Test Environment would remove my need for Truffle.

2 Likes

Hey @msolomon4!
All other Ganache configurations such as unlock will be supported because as you say they are essential for building on top of existing mainnet contracts.
Is your project open-source? Would you mind to share a link for your tests?

1 Like

Hey @andygray!
Welcome to the forum!

Time is always the next tricky things. Being able to keep the blocks and timestamp in sync and moving to a moment in the future consistently.

How do you solve that right now? Do you use evm_mine for that?

We also use gas estimations a lot with balances - guess these two are more for test-helpers though.
Have you seen eth-gas-reporter? Is it valuable for your use case?

We use a couple of scripts locally, 1 to run in with compile, 1 without compile for speed. Might want to document this approach?

Can you clarify that a bit? To run you dApp?

1 Like

Yep, all open source! Here’s links to two recent projects where we have forked the mainnet for development and testing.


3 Likes

Now this is what I am talking about! Am eagerly waiting for both the coverage and ganache-Fork testing. By the way, I also highly use the eth-gas-reporter, so please do consider that too. For most of the test, I am relying on web3js test or truffle.

2 Likes

Hey team, I’m excited for this release. 100% coverage is a pretty good great accomplishment.

I haven’t used Ganache in over a year, and have been using https://oneclickdapp.com/ (OCD) since. It wont take that much to add a plugin for that, there is already an integration between OCD and remix. Most of the defi tools are still relying on web3 injecting wallets like metamask and others now. So part of my dev process is using those web wallets to test on local networks + OCD so I can see how the flow is on web super fast. Please consider adding a native integration here, or creating a bounty on gitcoin for it.

2 Likes

Hey @jschiarizzi! I’ve checked out OCD seems as a cool project. Can you clarify a bit more what kind of integration with test-env you have in mind?

1 Like

Thanks for dropping into conversation @amateur-dev! It is nice to hear that you use eth-gas-reporter. We are considering it. That would be one more point.

2 Likes

Hi OZ team, thanks for what you have built already built, it’s rapid quick and generally topnotch!

For me the two things which I would love to see supported are Solidity coverage and Gas reporting.

Adding either of those would be great and massively appreciated.

3 Likes

Hey @jamesmorgan! Thanks for responding. Solidity Coverage is a next feature on our list. Working hard to deliver it!

2 Likes

Excellent - nice to see Test Environment going forward!

My only grief is more narrative documetation :slight_smile: Also, some side-by-side comparison with Truffle and Web3 objects, so that people who have some legacy experience can adopt it faster.

1 Like

Hi @miohtama,

Would you mind creating an issue with your suggestions for improving the documentation?

If you have the time, you could also discuss with @ylv-io (the project owner) to see if they would like you to do a PR to make the improvements.

Thank you. Here is an open issue

1 Like

Hi @miohtama,

Apologies, I had forgotten that you had already created an issue for this. Thank you.

Thank you @abcoathup.

“Developer experience” is not a a feature and very intangible, but still important!

1 Like

Any updates on adding Solidity Coverage to the testing environment?

1 Like

Hi @Watt3r,

Welcome to the community :wave:

There isn’t any updates on adding coverage to OpenZeppelin Test Environment. I will reply here when there is news.