Skip to content

Commit

Permalink
test: Basic test setup
Browse files Browse the repository at this point in the history
Make sure the tests can be ran easily.
This is the first of a list of change aiming at improving the test setup.
We will try to keep the changes simple and iterate rather than making a
giant pull request that would be painful to be reviewed and merged.

Note that the `rpcUrls.test.js` file was added back to tracking and
leverages `process.env`. Alternatively we could add dotenv as a dev
dependency and use (untracked) `.env` files for RPC URLs.

A lot of tests are still failing but at least some pass.
Fixing tests will be addressed in follow up pull requests.

Tested with both Hardhat and Anvil exporting `ETH_RPC` as:
```
export ETH_RPC=http://127.0.0.1:8545
```

In follow up pull requests we want to:
- fix or skip broken tests
- run tests from the CI
  • Loading branch information
AndreMiras committed Oct 4, 2024
1 parent 79fe005 commit a60fd64
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ package-lock.json
pnpm-lock.yaml
yarn.lock
test/temp.test.ts
test/rpcUrls.test.ts
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2462,3 +2462,9 @@ import curve from "@curvefi/api";
// ]
})()
```
## Tests
```sh
npm run test
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"scripts": {
"build": "rm -rf lib && tsc -p tsconfig.build.json",
"test": "npx tsc && mocha dist/test/*.test.js",
"lint": "eslint src --ext .ts"
},
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion test/apy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import curve from "../src/index.js";
import { curve as _curve } from "../src/curve.js";
import { getPool, PoolTemplate } from "../src/pools/index.js";
import { IReward } from "../src/interfaces.js";
import { ETH_RPC, OPTIMISM_RPC, XDAI_RPC, POLYGON_RPC, FANTOM_RPC, MOONBEAM_RPC, KAVA_RPC, ARBITRUM_RPC, CELO_RPC, AVALANCHE_RPC, AURORA_RPC } from "./rpcUrls.test.js";
import { ETH_RPC } from "./rpcUrls.test.js";


const poolStatsTest = (name: string) => {
Expand Down
2 changes: 1 addition & 1 deletion test/factoryPoolsData.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from "chai";
import { curve } from "../src/curve.js";
import { ETH_RPC, ARBITRUM_RPC, AURORA_RPC } from "./rpcUrls.test.js";
import { ETH_RPC } from "./rpcUrls.test.js";
import { IDict, IPoolData } from "../src/interfaces.js";
import { BLACK_LIST } from "../src/factory/factory.js";

Expand Down
1 change: 1 addition & 0 deletions test/rpcUrls.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const { ETH_RPC } = process.env;

0 comments on commit a60fd64

Please sign in to comment.