Skip to content

Commit e4e9e04

Browse files
committed
feat: ci cd (#4630)
Signed-off-by: Mariusz Jasuwienas <[email protected]>
1 parent 96903f1 commit e4e9e04

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

.github/workflows/acceptance.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- { name: 'Websocket Batch 3', testfilter: 'ws_batch3', test_ws_server: true }
3939
- { name: 'Cache Service', testfilter: 'cache-service' }
4040
- { name: 'Server Config', testfilter: 'serverconfig' }
41+
- { name: 'JSON RPC semantics and response codes compliance', testfilter: 'json_rpc_compliance' }
4142
uses: ./.github/workflows/acceptance-workflow.yml
4243
with:
4344
testfilter: ${{ matrix.test.testfilter }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"acceptancetest:rpc_api_schema_conformity": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@api-conformity' --exit",
6868
"acceptancetest:serverconfig": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@server-config' --exit",
6969
"acceptancetest:send_raw_transaction_extension": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@sendRawTransactionExtension' --exit",
70+
"acceptancetest:json_rpc_compliance": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@json-rpc-compliance' --exit",
7071
"acceptancetest:debug": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@debug' --exit",
7172
"acceptancetest:xts": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@xts' --exit",
7273
"build": "npx lerna run build",

packages/server/src/compliance.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ export const INVALID_METHOD_RESPONSE_BODY = {
2727
};
2828

2929
const makeSureBodyExistsAndCanBeChecked = (ctx: IResponseContext) => {
30+
if (ctx.status === 404) return false;
31+
3032
if (!ctx.body) {
3133
ctx.status = 400;
32-
ctx.body = { ...FALLBACK_RESPONSE_BODY };
34+
ctx.body = structuredClone(FALLBACK_RESPONSE_BODY);
3335
return false;
3436
}
3537

@@ -40,7 +42,7 @@ const makeSureBodyExistsAndCanBeChecked = (ctx: IResponseContext) => {
4042

4143
if (typeof ctx.body !== 'object') {
4244
ctx.status = 400;
43-
ctx.body = { ...FALLBACK_RESPONSE_BODY };
45+
ctx.body = structuredClone(FALLBACK_RESPONSE_BODY);
4446
return false;
4547
}
4648
if (!ctx.body.jsonrpc) ctx.body.jsonrpc = FALLBACK_RESPONSE_BODY.jsonrpc;
@@ -59,7 +61,7 @@ const makeSureBodyExistsAndCanBeChecked = (ctx: IResponseContext) => {
5961
export const jsonRpcComplianceLayer = (ctx: IResponseContext & ParameterizedContext) => {
6062
if (!makeSureBodyExistsAndCanBeChecked(ctx)) return;
6163
if (ctx.status === 400) {
62-
if (!ctx.body.error?.code) ctx.body.error = FALLBACK_RESPONSE_BODY.error;
64+
if (!ctx.body.error?.code) ctx.body.error = structuredClone(FALLBACK_RESPONSE_BODY.error);
6365
if (VALID_JSON_RPC_HTTP_REQUESTS_STATUS_CODE) ctx.status = 200;
6466
}
6567
};

packages/server/tests/acceptance/responseCodes.spec.ts renamed to packages/server/tests/acceptance/jsonRpcCompliance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { overrideEnvsInMochaDescribe } from '../../../relay/tests/helpers';
77
import { RELAY_URL } from './data/conformity/utils/constants';
88
import { JsonRpcResponse } from './data/conformity/utils/interfaces';
99

10-
describe('@json-rpc HTTP/JSON-RPC semantics acceptance tests', function () {
10+
describe('@json-rpc-compliance HTTP/JSON-RPC semantics acceptance tests', function () {
1111
this.timeout(60000);
1212

1313
const baseURL = RELAY_URL;

packages/server/tests/integration/server.spec.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,17 @@ describe('RPC Server', function () {
301301
expect(res.data.result).to.be.equal('0xf956fddff3899ff3cf7ac1773fdbf443ffbfb625c1a673abdba8947251f81bae');
302302
});
303303

304-
it.skip('should execute "eth_getTransactionByHash with missing transaction"', async function () {
305-
// Fixme, why it works locally, but not here??
306-
const res = await testClient.post('/', {
307-
id: '2',
308-
jsonrpc: '2.0',
309-
method: RelayCalls.ETH_ENDPOINTS.ETH_GET_TRANSACTION_BY_HASH,
310-
params: ['0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7237170ae5e5e7957eb6392'],
311-
});
312-
expect(res.data.result).to.be.null;
304+
it('should execute "eth_getTransactionByHash with missing transaction"', async function () {
305+
try {
306+
await testClient.post('/', {
307+
id: '2',
308+
jsonrpc: '2.0',
309+
method: RelayCalls.ETH_ENDPOINTS.ETH_GET_TRANSACTION_BY_HASH,
310+
params: ['0x4a563af33c4871b51a8b108aa2fe1dd5280a30dfb7237170ae5e5e7957eb6392'],
311+
});
312+
} catch (error: any) {
313+
expect(error.message).to.equal('Request failed with status code 404');
314+
}
313315
});
314316

315317
it('should execute "eth_getUncleByBlockHashAndIndex"', async function () {

0 commit comments

Comments
 (0)