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

Hardhat tests #25

Merged
merged 18 commits into from
Nov 23, 2021
Merged

Hardhat tests #25

merged 18 commits into from
Nov 23, 2021

Conversation

willpote
Copy link
Contributor

Jest -> Mocha in order to make hardhat tests work.

Simulate swaps using hardhat fork for the quote integ tests

@willpote willpote requested a review from ewilz November 19, 2021 22:05
defaultNetwork: 'hardhat',
networks: {
hardhat: {
blockGasLimit: 150_000_000,
Copy link
Member

@ewilz ewilz Nov 19, 2021

Choose a reason for hiding this comment

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

this is bc 10x block gas limit for static calls??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this isn't needed since we don't do the static calls in the tests. This was copy pasted from another project where I was doing huge static calls. Will remove

forking: {
enabled: true,
url: `${process.env.ARCHIVE_NODE_RPC}`,
blockNumber: 12972642,
Copy link
Member

Choose a reason for hiding this comment

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

hmm...is this for predictable test results?? wonder if there'd be a way to test things without needing exact numbers...haven't thought it through yet though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this was copy pasted over too and isn't needed.

The tests already don't require exact numbers. Currently I check the users balance before and after the swap

e.g. For example for an exactIn swap of 100, i check the user has 100 less of tokenIn after the swap. I don't check tokenOut, but thinking more about it- i think it would be valuable to check token out is within slippage percentage of the quote. Ill add some more checks

percentDiff.denominator
}), quote: ${tokensQuoted.toExact()}, rceived: ${tokensSwapped.toExact()}`
) */
expect(percentDiff.lessThan(new Fraction(5, 100))).to.be.true
Copy link
Member

Choose a reason for hiding this comment

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

where does this figure come from??

Copy link
Contributor Author