File tree Expand file tree Collapse file tree 5 files changed +19
-13
lines changed
Expand file tree Collapse file tree 5 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 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 }}
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change @@ -27,9 +27,11 @@ export const INVALID_METHOD_RESPONSE_BODY = {
2727} ;
2828
2929const 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) => {
5961export 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} ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { overrideEnvsInMochaDescribe } from '../../../relay/tests/helpers';
77import { RELAY_URL } from './data/conformity/utils/constants' ;
88import { 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 ;
Original file line number Diff line number Diff 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 ( ) {
You can’t perform that action at this time.
0 commit comments