Skip to content
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

Migrating to buidler #492

Merged
merged 105 commits into from
Apr 16, 2020
Merged

Migrating to buidler #492

merged 105 commits into from
Apr 16, 2020

Conversation

jjgonecrypto
Copy link
Contributor

@jjgonecrypto jjgonecrypto commented Apr 2, 2020

  • All contract tests ported to Buidler
  • Removed migration script, replaced with setup utility to mock where possible
  • Added support for coverage
  • Ported our testnet:local and test:publish to use buidler-evm

test-contracts runs in under 6m, down from nearly an hour! 🙇

Note: the final missing piece is buidler-gas-reporter which a) isn't working with the latest buidler due to the limiting peerDependency and b) even when manually updated, produces empty reports. I'll look into this in a separate PR with a fork (@cgewecke)

@codecov
Copy link

codecov bot commented Apr 2, 2020

Codecov Report

Merging #492 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #492   +/-   ##
========================================
  Coverage    92.04%   92.04%           
========================================
  Files           39       39           
  Lines         1985     1985           
  Branches       271      271           
========================================
  Hits          1827     1827           
  Misses         158      158           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ceafab...0ceafab. Read the comment docs.

@jjgonecrypto
Copy link
Contributor Author

jjgonecrypto commented Apr 3, 2020

@cgewecke running npx @nomiclabs/buidler coverage is failing with Error: Returned error: Transaction gas limit is 1099511627775 and exceeds block gas limit of 9500000 even though I'm using the same .solcover.js file that works with truffle. I've tried adding gasLimit: 9e12 to providerOptions but no luck. Any other thoughts?

(run npm run coverage:unit to repro)

@jjgonecrypto jjgonecrypto marked this pull request as ready for review April 15, 2020 20:46
@@ -140,11 +149,14 @@ contract('Exchanger (via Synthetix)', async accounts => {
describe('and 88 seconds elapses', () => {
// Note: timestamp accurancy can't be guaranteed, so provide a few seconds of buffer either way
beforeEach(async () => {
fastForward(88);
await fastForward(87);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this supposed to be 87 or 88 as described?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was tinkering with it due to timing issues in the setup and forgot to put this back. Doing it now. 👍

@@ -281,11 +277,11 @@ contract('RewardEscrow', async accounts => {
await assert.revert(
rewardEscrow.appendVestingEntry(account1, toUnit('1'), { from: feePoolAccount })
);
});
}).timeout(60e3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What affect will this have? will it fail the test if it times out or about this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows individual tests to extend the default mocha timeout (which I believe is 20 secs): https://mochajs.org/#timeouts

I use the it().timeout() functionality as this.timeout(...) does not work with fat arrow functions due to the fact that they update this with the global context in the top-level contract or describe block.

test/contracts/RewardsIntegrationTests.js Show resolved Hide resolved
test/contracts/RewardsIntegrationTests.js Outdated Show resolved Hide resolved
// get rawLogs as logs not decoded because the truffle cannot decode the events from the
// underlying from the proxy invocation
const { topics } = txn.receipt.rawLogs[0];
assert.equal(topics[1], web3.eth.abi.encodeParameter('address', account3));
Copy link
Contributor

@jacko125 jacko125 Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good check here that messageSender set as from acc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😊

test/contracts/ProxyERC20.js Outdated Show resolved Hide resolved
@jjgonecrypto
Copy link
Contributor Author

Additional improvements:

  1. I removed the web3 artifacts and contracts globals from .eslintrc.js and explicitly called out their usages in all tests
  2. I added use strict headers to all tests
  3. I took the inflationStartTimestampInSecs number and added it to the synthetix module and ensured everything used that number (rather than hardcoding it across the deployment and tests)
  4. I made the snapshot and restores before and after tests explicit and used there where necessary. Please note that because some tests require the blocktime to start explicitly at inflationStartTImestampInSecs that every test that uses fastForward must also use snapshots to ensure that they don't pollute the EVM by upping the timestamp. @jacko125 this is a good reason to make the tests more robust and allow them to take any inflation start time rather than having to use the hard-coded amount.
  5. I explicitly added chai.assert to match the truffle assertions we were using
  6. I ensured this assert was cloned and only that mutation be exported.
  7. I moved around test utilities and helpers to ensure only test/utils/index.js be the test utility file we share among different types of tests

@jjgonecrypto jjgonecrypto merged commit c9afbf5 into develop Apr 16, 2020
@jjgonecrypto jjgonecrypto deleted the migrating-to-buidler branch April 16, 2020 23:58
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

Successfully merging this pull request may close these issues.

5 participants