Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
coverage/*
node_modules/*
build/*
.eslintrc.js
.eslintrc.js
.eslintrc.cjs
1 change: 1 addition & 0 deletions backend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/no-var-requires': 0,
'no-console': ['error'],
},
};
26 changes: 24 additions & 2 deletions backend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest',
preset: 'ts-jest/presets/js-with-ts-esm',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
testEnvironment: 'node',
};

testPathIgnorePatterns: [
'/node_modules/',
'/build/'
],
resetModules: true,
testTimeout: 30000,
coverageThreshold: {
global: {
statements: 95,
branches: 75,
functions: 100,
lines: 95,
},
},
coveragePathIgnorePatterns: [
'src/server.ts',
'src/plugins/config.ts',
],
}
3 changes: 3 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@account-abstraction/utils": "0.5.0",
"@aws-sdk/client-secrets-manager": "3.410.0",
"@fastify/cors": "8.4.1",
"@fastify/redis": "^6.1.1",
"@sinclair/typebox": "0.31.28",
"ajv": "8.11.2",
"dotenv": "16.0.3",
Expand All @@ -43,6 +44,7 @@
"devDependencies": {
"@babel/core": "7.23.2",
"@babel/preset-env": "7.23.2",
"@babel/preset-typescript": "^7.23.3",
"@types/jest": "29.5.3",
"@types/node": "18.11.15",
"@typescript-eslint/eslint-plugin": "5.45.0",
Expand All @@ -52,6 +54,7 @@
"eslint": "8.28.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.2.1",
"husky": "^8.0.3",
"jest": "29.6.2",
"pino-pretty": "8.1.0",
"prettier": "2.8.0",
Expand Down
1 change: 0 additions & 1 deletion backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ await server.register(cors, {
preflightContinue: true
})


await server.register(config);
await server.register(routes);
await server.register(fastifyCron, {
Expand Down
29 changes: 0 additions & 29 deletions backend/test/helper.ts

This file was deleted.

53 changes: 20 additions & 33 deletions backend/test/routes.test.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
import { build } from './helper'
import { FastifyInstance } from 'fastify';
import server from '../src/server.js';

describe('root tests', () => {
const app = build();
const app = server as FastifyInstance;

test('default root route without params', async () => {
const res = await app.inject({
url: '/',
method: "POST"
})
expect(JSON.parse(res.payload)).toEqual({ error: 'Empty Body received'})
})
beforeEach(() => {
jest.clearAllMocks();
});

test('default etherspot paymaster with params', async () => {
const userOp = {
sender: "0x603Ef162f05dDa6e3B4717f4A951d6eF614a897f",
nonce: "0x1d",
initCode: "0x",
callData: "0x47e1da2a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000080a1874e1046b1cc5defdf4d3153838b72ff94ac0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000",
callGasLimit: "0x8342",
verificationGasLimit: "0x16070",
maxFeePerGas: "0x7d912eba",
maxPriorityFeePerGas: "0x7d912eaa",
paymasterAndData: "0x",
preVerificationGas: "0xa96c",
signature: "0x"
};
const res = await app.inject({
url: '/',
method: "POST",
payload: {params: [userOp, "0x603Ef162f05dDa6e3B4717f4A951d6eF614a897f"]},
});
expect(res.statusCode).toEqual(200);
expect(JSON.parse(res.payload)).toHaveProperty('paymasterAndData');
})
afterAll(async () => {
await app.close();
jest.clearAllMocks();
});

describe('HealthCheck Routes', () => {
test('should respond with success status', async () => {
const response = await app.inject({
method: 'GET',
url: '/healthCheck',
});

})
expect(response.statusCode).toBe(200);
});
});
19 changes: 0 additions & 19 deletions backend/test/tsconfig.test.json

This file was deleted.

1 change: 1 addition & 0 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "ESNext",
"moduleResolution": "Node",
"lib": ["esnext"],
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
Expand Down
13 changes: 13 additions & 0 deletions backend/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"isolatedModules": true,
},
"include": [
"**/*.test.ts",
"**/*.spec.ts"
],
"exclude": [
"./node_modules/",
"./build/"
]
}