OpenZeppelin / openzeppelin-test-environment

[Not actively maintained] One-line setup for blazing-fast smart contracts tests
https://docs.openzeppelin.com/test-environment
MIT License
90 stars 39 forks source link

please god, please ethers support #133

Open SilentCicero opened 4 years ago

SilentCicero commented 4 years ago

Hi all,

Really happy to see some Truffle suite alternatives.

But, I have one comment: ethers.js, ethers.js, ethers.js, ethers.js

Please support ethers.js contracts / preferences.

Best, Ethereum Friend.

frangio commented 4 years ago

Thank you for the feedback @SilentCicero. We will definitely keep this in mind for planning.

mds1 commented 4 years ago

I'd also love to see ethers.js support.

This will spill over into @openzeppelin/test-helpers, since expectEvent doesn't support ethers-style receipts, though I assume you're already aware of this.

Another thing to consider when supporting this is to make sure it supports ganache forks properly. I tried using ethers in testing manually, but as soon as contract development progressed to the stage of needing to fork the mainnet, transactions started failing.

For example, these lines worked until I started forking the mainnet:

const TestToken = contract.fromArtifact('TestToken');
const tokenFactory = new ethers.ContractFactory(TestToken.abi, TestToken.bytecode, wallet);
usdc = await tokenFactory.deploy('USD Coin', 'USDC');
await usdc.deployTransaction.wait();

When forking, the above fails with Error: Missing required chain parameter: networkId

You can confirm the issue is related to ethers.js usage because if you refactor to the below, the transaction succeeds again:

const TestToken = contract.fromArtifact('TestToken');
const usdc = await TestToken.new("USD Coin", "USDC");