Skip to content

Commit

Permalink
Moving integration tests from routing-api into SOR (#92) (#95)
Browse files Browse the repository at this point in the history
* Moving integration tests from routing-api into SOR (#92)

* refactor test-utils and add integ folder

* Add hardhat^2.6.8

* Add @nomiclabs/hardhat-ethers

* Add ERC20 external types

* trying to figure out hardhat import errors

* remove adjustments to tsconfig.json

* Add mising imports

* finally got integration tests to work with [email protected]

* Update plugin to 1.0.1 and fix approve param typing

* Add erc20-eth test, simulated execute swaps still broken

* Clean up code

* remove unused forkAndFund

* Add new jest-environment-hardhat plugin and confirm integ tests pass

* Add erc20-eth large trade and confirm routeString test passes

* Add more checks

* Change slippage to match CLI use

* Update forking blockNumber, fix executeSwaps problem, introduce routing exact out error

* Fix weird v3 quote provider issue by bumping ethers to 5.6.1

* Fix token ordering issue, remove v3poolprovider stuff from route processing

* Pass all tests :)

* Fix out of gas error with hardcoded blockGasLimit in hardhat config

* Finish implementing all of the mainnet tests

* Remove console.logs in quote provider

* Condense last few tests & all tests pass!

* scratch that one test is failing, maybe due to some ERC20 token dust?

* Add comments

* Fix lodash lib error

* remove unused file

* fix local var problem

* Add integ tests for non mainnet chains, all pass except optimism

* Fix native test for non mainnet with nativeOnChain

* Drop scoped jest-env-hardhat for new version 1.1.4

* skip failing test due to known error #94

* remove console.logs and comments

* Remove unused file, clean up comments

* Revisions - generalize helper functions and use them more

* reformat quoteProvider and alpha-router with prettier and address more integ tests revisions

* Fix broken test

Co-authored-by: Eric Zhong <[email protected]>

* Fix code style issues with Prettier

* bump typechain, @typechain/ethers-v5

* try downgrading ethers

* bump typechain/ethers way up to 10

* drop typechain back to before, add ethersproject/[email protected]

* make npm run test only run test/unit

* Add better comments, remove stuff from testing

* oops I removed the actual approve call on accident

* Fix eip-1559 gas provider hex string, fork from latest avail block now

* Bump jest-environment-hardhat to 1.1.8

* Add deprecated comment for QuoteResponse type

* move UNI_GORLI upwards to other gorli tokens

* Update GH actions workflow to fetch secrets into env and change package.json script

* funky O

* drop 'standard' from validateStandardSwapRoute

* minor comment change

* integ tests pass on actions but take way too long, fallback to running unit until fix

* Revisions: remove `parseRouteFromSwap`, and all instances of passing strings and exacts

* change checkToken_Amount params to number and comment fixes

* comment param changes

* Remove now unused parseSwap func

* Change param names from currencyIn to match tokenIn in rest of file

* Fix failing tests - add helper to expandDecimals, and fix amountEdgesTotal

* remove .only

* fix typo in expandDecimals

* unskip other chain tests

* Remove hardhat.fork() since not pinning block

Co-authored-by: Lint Action <[email protected]>
  • Loading branch information
zhongeric and lint-action authored Jun 15, 2022
1 parent 172bcd3 commit 6ca2a5c
Show file tree
Hide file tree
Showing 23 changed files with 11,982 additions and 7,088 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ jobs:

- name: Run unit tests
run: npm run test
env:
JSON_RPC_PROVIDER: ${{ secrets.JSON_RPC_PROVIDER }}
JSON_RPC_PROVIDER_RINKEBY: ${{ secrets.JSON_RPC_PROVIDER_RINKEBY }}
JSON_RPC_PROVIDER_ROPSTEN: ${{ secrets.JSON_RPC_PROVIDER_ROPSTEN }}
JSON_RPC_PROVIDER_KOVAN: ${{ secrets.JSON_RPC_PROVIDER_KOVAN }}
JSON_RPC_PROVIDER_GORLI: ${{ secrets.JSON_RPC_PROVIDER_GORLI }}
JSON_RPC_PROVIDER_OPTIMISM: ${{ secrets.JSON_RPC_PROVIDER_OPTIMISM }}
JSON_RPC_PROVIDER_ARBITRUM_ONE: ${{ secrets.JSON_RPC_PROVIDER_ARBITRUM_ONE }}
JSON_RPC_PROVIDER_POLYGON: ${{ secrets.JSON_RPC_PROVIDER_POLYGON }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ yarn.lock
types
types/*
.env
cache/
21 changes: 21 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require('@nomiclabs/hardhat-ethers');

const dotenv = require('dotenv');

dotenv.config();

const mainnetFork = {
url: `${process.env.JSON_RPC_PROVIDER}`,
};

module.exports = {
networks: {
hardhat: {
chainId: 1,
forking: mainnetFork,
accounts: {
count: 2,
},
},
},
};
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node', 'd.ts'],
/**
* @note use this if we have multiple integration test files
*/
// testEnvironment: "jest-environment-hardhat"
};
Loading

0 comments on commit 6ca2a5c

Please sign in to comment.