Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Add E2E tests for PSP #55

Merged
merged 26 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ef7d92d
Setup psp e2e test
vponline Apr 5, 2022
ff0b9a0
Merge branch 'process-refactor' into psp-e2e-test
vponline Apr 5, 2022
72547d5
Setup build step
vponline Apr 5, 2022
ef0184d
Silence logger for e2e, set hardhat defaults
vponline Apr 5, 2022
af431cb
Fix hardhat config
vponline Apr 5, 2022
ca206ac
Merge branch 'process-refactor' into psp-e2e-test
vponline Apr 5, 2022
0a67aff
Add fs mock, invalid test cases
vponline Apr 6, 2022
1a7a863
Merge branch 'process-refactor' into psp-e2e-test
vponline Apr 6, 2022
2d06339
Add subscription steps
vponline Apr 6, 2022
82feb71
Mock env, fix config mocks
vponline Apr 6, 2022
ba1675c
Set timeout
vponline Apr 6, 2022
19f3bcf
Remove beforeEach
vponline Apr 6, 2022
9e43c68
Move jest timeout, fix airnodeConfig mock
vponline Apr 6, 2022
d18be5e
Update hardhat version - fixes missing ethereum node logs
vponline Apr 6, 2022
cfa23d1
Apply pr suggestions, reset hardhat network for each test, check dapi…
vponline Apr 8, 2022
bec52ec
Update README with test instructions
vponline Apr 8, 2022
dcabcd5
Add api call retry test case
vponline Apr 8, 2022
236c429
Merge branch 'main' into psp-e2e-test
vponline Apr 12, 2022
1a297da
Add second valid subscription
vponline Apr 12, 2022
d7b4ee5
Use real subscription for invalid test, remove unnecessary pm2 settings
vponline Apr 12, 2022
e9ea03c
Add comment about subscriptions to localConfigs
vponline Apr 12, 2022
41ced4c
Refactor, move test folder
vponline Apr 12, 2022
4e6665f
Add spaces to comments
vponline Apr 12, 2022
edc9fab
Fix hardhat file .gitignore
vponline Apr 12, 2022
bfb6380
Derive beaconId instead of reading from contract
vponline Apr 13, 2022
fa75a2e
Fix tsconfig
vponline Apr 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/node_modules/**
**/dist/**
**/cache/**
.prettierignore
22 changes: 21 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ jobs:
run: yarn install --frozen-lockfile
- name: Test
run: yarn test
e2e-tests:
name: E2E tests
runs-on: ubuntu-latest
needs: lint-compile
steps:
- name: Clone Airkeeper
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Start background services
run: yarn run dev:background
- name: Test
run: yarn test:e2e
docker-build:
name: Build docker image and push to Docker Hub
runs-on: ubuntu-latest
Expand All @@ -76,7 +96,7 @@ jobs:
build-complete:
name: All tests passed
runs-on: ubuntu-latest
needs: [documentation, docker-build, unit-tests]
needs: [documentation, docker-build, unit-tests, e2e-tests]
steps:
- run: exit 0
- name: Slack Notification
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ aws.env
**/psp-beacon-local.json

# Temporarily add airnode for unpublished changes
airnode
airnode

# Hardhat files
cache

# Ignore log files
logs
*.log
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Ignore artifacts:
**/.build/**
**/dist/**
**/cache/**
**/.serverless/**
**/coverage/**

**/config/*.json
**/node_modules/**
Copy link
Contributor

Choose a reason for hiding this comment

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

We also want to add airnode here temprarily.

**/node_modules/**
42 changes: 42 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// eslint-disable-next-line functional/immutable-data
module.exports = {
apps: [
{
name: 'web-api',
script: 'ts-node src/test/server/server.ts',
env: {
NODE_ENV: 'development',
},
env_production: {
NODE_ENV: 'production',
},

// Logs
log_date_format: 'YYYY-MM-DD HH:mm:ss',
error_file: 'logs/web-api.log',
out_file: 'logs/web-api.log',
merge_logs: true,

// Watching
watch: ['src'],
watch_delay: 500,
ignore_watch: ['node_modules'],
vponline marked this conversation as resolved.
Show resolved Hide resolved
},
{
name: 'ethereum-node',
script: 'hardhat node --config src/test/hardhat.config.ts',
env: {
NODE_ENV: 'development',
},
env_production: {
NODE_ENV: 'production',
},

// Logs
log_date_format: 'YYYY-MM-DD HH:mm:ss',
error_file: 'logs/ethereum-node.log',
out_file: 'logs/ethereum-node.log',
merge_logs: true,
},
],
};
9 changes: 9 additions & 0 deletions jest-e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const config = require('./jest.config');

// eslint-disable-next-line functional/immutable-data
module.exports = {
...config,
name: 'e2e',
displayName: 'e2e',
testMatch: ['**/?(*.)+(feature).[tj]s?(x)'],
};
9 changes: 9 additions & 0 deletions jest-unit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const config = require('./jest.config');

// eslint-disable-next-line functional/immutable-data
module.exports = {
...config,
displayName: 'unit',
name: 'unit',
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
};
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
// eslint-disable-next-line functional/immutable-data
module.exports = {
projects: ['<rootDir>/jest-e2e.config.js', '<rootDir>/jest-unit.config.js'],
// All imported modules in your tests should be mocked automatically
// automock: false,

Expand Down
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
"clean": "rimraf -rf ./dist *.tgz",
"compile": "tsc -p tsconfig.json",
"compile:build": "tsc -p tsconfig-build.json",
"dev:clean": "rimraf -rf ./logs",
"dev:list": "pm2 list",
"dev:stop": "pm2 stop ecosystem.config.js",
"dev:delete": "pm2 delete all",
"dev:eth-node": "hardhat node --config src/test/hardhat.config.ts",
vponline marked this conversation as resolved.
Show resolved Hide resolved
"dev:api": "ts-node src/test/server/server.ts",
"dev:background": "yarn run dev:clean && pm2 start ecosystem.config.js",
"lint": "yarn run prettier:check && yarn run lint:eslint",
"lint:eslint": "eslint . --ext .js,.ts",
"prettier:check": "prettier --check \"./**/*.{js,sol,ts,md,yml,json}\"",
Expand All @@ -31,7 +38,8 @@
"sls:invoke:psp-beacon-update": "sls invoke --function psp-beacon-update",
"sls:invoke-local:psp-beacon-update": "yarn build && sls invoke local --function psp-beacon-update --param='provider=local'",
"setup:psp-local": "tsc && node scripts/psp-beacon-local-setup.js",
"test": "jest",
"test": "jest --selectProjects unit",
"test:e2e": "SILENCE_LOGGER=true jest --selectProjects e2e",
"prepare": "husky install"
},
"dependencies": {
Expand All @@ -44,13 +52,18 @@
"aws-sdk": "^2.1101.0",
"dotenv-safe": "^8.2.0",
"ethers": "^5.6.0",
"express": "^4.17.3",
"lodash": "^4.17.21",
"morgan": "^1.10.0",
"pm2": "^5.2.0",
vponline marked this conversation as resolved.
Show resolved Hide resolved
"zod": "^3.13.4"
},
"devDependencies": {
"@types/dotenv-safe": "^8.1.2",
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.179",
"@types/morgan": "^1.9.3",
"@types/node": "^17.0.21",
"@types/serverless": "^3.0.1",
"@typescript-eslint/eslint-plugin": "^5.15.0",
Expand All @@ -59,6 +72,7 @@
"eslint-plugin-functional": "^4.2.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.0",
"hardhat": "^2.9.2",
"husky": "^7.0.4",
"jest": "^27.4.7",
"lint-staged": "^12.3.5",
Expand Down