Skip to content

Commit ed5135e

Browse files
feat: run all test locally (#1493)
Co-authored-by: Alexandre ABRIOUX <alexandre-abrioux@users.noreply.github.com>
1 parent ccfaf0d commit ed5135e

File tree

21 files changed

+198
-40
lines changed

21 files changed

+198
-40
lines changed

Dockerfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
FROM node:16-alpine
1+
FROM node:18-alpine
2+
RUN apk add --no-cache git
3+
RUN npm install -g solc
24

3-
WORKDIR /app
5+
## Warning! This Docker config is meant to be used for development and debugging, not in prod.
46

5-
RUN apk add --virtual .build-deps git python g++ bash make
7+
WORKDIR /base
68

79
COPY package.json .
810
COPY yarn.lock .
9-
10-
RUN yarn
11+
RUN yarn install && \
12+
yarn cache clean
1113

1214
COPY . .
13-
RUN yarn
14-
RUN yarn build
15+
RUN yarn clean && \
16+
yarn build && \
17+
yarn cache clean
1518

16-
RUN apk del .build-deps
19+
# Port configuration
20+
ENV PORT 3000
21+
EXPOSE 3000

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ yarn run lint
7979

8080
Test all the packages in the monorepo.
8181

82+
Some tests will require services to be running locally
83+
84+
```bash
85+
docker compose up
86+
```
87+
88+
Deploy Smart Contracts
89+
90+
```bash
91+
yarn run deploy:contracts
92+
```
93+
94+
Run request-node locally
95+
96+
```bash
97+
cp ./packages/request-node/.env.example ./packages/request-node/.env
98+
yarn run start:request-node
99+
```
100+
101+
Run all tests
102+
82103
```bash
83104
yarn run test
84105
```
@@ -89,6 +110,12 @@ Test a specific package by replacing `@requestnetwork/request-client.js` with th
89110
yarn workspace @requestnetwork/request-client.js test
90111
```
91112

113+
Clean Docker Volumes
114+
115+
```bash
116+
docker compose down -v
117+
```
118+
92119
## License
93120

94121
[MIT](https://github.com/RequestNetwork/requestNetwork/blob/master/LICENSE)

docker-compose.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Warning! This Docker config is meant to be used for development and debugging, specially for running tests, not in prod.
2+
services:
3+
graph-node:
4+
image: graphprotocol/graph-node:v0.25.0
5+
ports:
6+
- '8000:8000'
7+
- '8001:8001'
8+
- '8020:8020'
9+
- '8030:8030'
10+
- '8040:8040'
11+
depends_on:
12+
- ipfs
13+
- postgres
14+
- ganache
15+
environment:
16+
postgres_host: postgres
17+
postgres_user: graph-node
18+
postgres_pass: let-me-in
19+
postgres_db: graph-node
20+
ipfs: 'ipfs:5001'
21+
ethereum: 'private:http://ganache:8545'
22+
RUST_LOG: info
23+
GRAPH_ALLOW_NON_DETERMINISTIC_IPFS: 1
24+
ipfs:
25+
image: requestnetwork/request-ipfs:v0.13.0
26+
ports:
27+
- '5001:5001'
28+
restart: on-failure:20
29+
# volumes:
30+
# - ./data/ipfs:/data/ipfs
31+
ganache:
32+
image: trufflesuite/ganache:v7.6.0
33+
ports:
34+
- 8545:8545
35+
command:
36+
- '-l'
37+
- '90000000'
38+
- '-m'
39+
- 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
40+
- '-k'
41+
- 'london'
42+
restart: on-failure:20
43+
postgres:
44+
image: postgres
45+
ports:
46+
- '5432:5432'
47+
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements']
48+
environment:
49+
POSTGRES_USER: graph-node
50+
POSTGRES_PASSWORD: let-me-in
51+
POSTGRES_DB: graph-node
52+
restart: on-failure:20
53+
graph-deploy:
54+
build:
55+
context: https://github.com/RequestNetwork/docker-images.git#main
56+
dockerfile: request-subgraph-storage/Dockerfile
57+
depends_on:
58+
- ipfs
59+
- postgres
60+
- graph-node
61+
- ganache
62+
environment:
63+
GRAPH_NODE: 'http://graph-node:8020'
64+
IPFS_HOST: 'ipfs:5001'
65+
KEEP_ALIVE: 0
66+
SUBGRAPH_FILE: 'subgraph-private.yaml'
67+
restart: on-failure:20

lerna.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"lerna": "3.2.1",
2+
"lerna": "6.6.2",
3+
"useWorkspaces": true,
34
"packages": ["packages/*"],
45
"version": "independent",
56
"npmClient": "yarn"

nx.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"tasksRunnerOptions": {
3+
"default": {
4+
"runner": "nx/tasks-runners/default",
5+
"options": {
6+
"cacheableOperations": ["build", "test"]
7+
}
8+
}
9+
},
10+
"targetDefaults": {
11+
"build": {
12+
"dependsOn": ["^build"]
13+
},
14+
"test": {
15+
"dependsOn": ["build"]
16+
}
17+
}
18+
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"publish-npm": "lerna publish --conventional-commits --exact",
2727
"publish-manual-prerelease": "lerna publish prerelease --conventional-commits --exact",
2828
"publish-prerelease": "yarn lerna publish --preid development --skip-git --yes --canary",
29-
"test": "lerna run test",
29+
"deploy:contracts": "yarn workspace @requestnetwork/smart-contracts deploy",
30+
"start:request-node": "yarn workspace @requestnetwork/request-node start",
31+
"test": "lerna run test --concurrency=1",
3032
"format": "prettier . -w",
3133
"format:check": "prettier . -c",
3234
"link:all": "for d in packages/*; do cd $d; yarn link; cd -; done",

packages/ethereum-storage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"clean": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
3636
"lint": "eslint . --fix",
3737
"lint:check": "eslint .",
38-
"test": "jest",
38+
"test": "jest --maxWorkers=1",
3939
"test:watch": "yarn test --watch",
4040
"init-ipfs": "node scripts/init-ipfs.js"
4141
},

packages/ethereum-storage/test/gas-fee-definer.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const gasFeeDefiner = new GasFeeDefiner({ provider, logger: console });
3636

3737
describe('Gas fee estimation', () => {
3838
it('Should not be undefined', async () => {
39+
provider.send('evm_increaseTime', [-60]);
40+
provider.send('evm_mine', []);
3941
const estimation = await gasFeeDefiner.getGasFees();
4042
expect(estimation.maxFeePerGas).toBeDefined();
4143
expect(estimation.maxPriorityFeePerGas).toBeDefined();
@@ -49,7 +51,7 @@ describe('Gas fee estimation', () => {
4951
await provider.send('evm_mine', []);
5052
const secondEstimation = await gasFeeDefiner.getGasFees();
5153

52-
expect(firstEstimation.maxFeePerGas?.toNumber()).toBeGreaterThan(
54+
expect(firstEstimation.maxFeePerGas?.toNumber()).toBeGreaterThanOrEqual(
5355
secondEstimation.maxFeePerGas?.toNumber() || 0,
5456
);
5557
});

packages/payment-detection/test/erc20/address-based-info-retriever.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('api/erc20/address-based-info-retriever', () => {
1010
describe('on localhost', () => {
1111
const paymentAddress = '0xf17f52151EbEF6C7334FAD080c5704D77216b732';
1212
const payerAddress = '0x627306090abaB3A6e1400e9345bC60c78a8BEf57';
13-
const emptyAddress = '0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef';
13+
const emptyAddress = '0x56dDdAA262139112d2490b50BE328D237a499A14';
1414

1515
it('can get the localhost balance of an address', async () => {
1616
const infoRetriever = new ERC20InfoRetriever(

packages/payment-processor/test/payment/batch-proxy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ describe('batch-proxy', () => {
736736
).toEqual(ETHTotal.toString());
737737
expect(toNewBalanceETH.sub(toOldBalanceETH)).toEqual(ETHAmount);
738738
expect(feeNewBalanceETH.sub(feeOldBalanceETH).toString()).toEqual(ETHFeesTotal.toString());
739-
});
739+
}, 20000);
740740
});
741741
});
742742

0 commit comments

Comments
 (0)