Skip to content

Commit a60fd64

Browse files
committed
test: Basic test setup
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
1 parent 79fe005 commit a60fd64

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ package-lock.json
66
pnpm-lock.yaml
77
yarn.lock
88
test/temp.test.ts
9-
test/rpcUrls.test.ts

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -2462,3 +2462,9 @@ import curve from "@curvefi/api";
24622462
// ]
24632463
})()
24642464
```
2465+
2466+
## Tests
2467+
2468+
```sh
2469+
npm run test
2470+
```

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"scripts": {
1717
"build": "rm -rf lib && tsc -p tsconfig.build.json",
18+
"test": "npx tsc && mocha dist/test/*.test.js",
1819
"lint": "eslint src --ext .ts"
1920
},
2021
"type": "module",

test/apy.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import curve from "../src/index.js";
33
import { curve as _curve } from "../src/curve.js";
44
import { getPool, PoolTemplate } from "../src/pools/index.js";
55
import { IReward } from "../src/interfaces.js";
6-
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";
6+
import { ETH_RPC } from "./rpcUrls.test.js";
77

88

99
const poolStatsTest = (name: string) => {

test/factoryPoolsData.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { assert } from "chai";
22
import { curve } from "../src/curve.js";
3-
import { ETH_RPC, ARBITRUM_RPC, AURORA_RPC } from "./rpcUrls.test.js";
3+
import { ETH_RPC } from "./rpcUrls.test.js";
44
import { IDict, IPoolData } from "../src/interfaces.js";
55
import { BLACK_LIST } from "../src/factory/factory.js";
66

test/rpcUrls.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const { ETH_RPC } = process.env;

0 commit comments

Comments
 (0)