@@ -27,7 +27,7 @@ import { Registry } from 'prom-client';
2727import sinon from 'sinon' ;
2828import cache from 'js-cache' ;
2929dotenv . config ( { path : path . resolve ( __dirname , '../test.env' ) } ) ;
30- import { RelayImpl } from '@hashgraph/json-rpc-relay' ;
30+ import { RelayImpl , predefined , MirrorNodeClientError } from '@hashgraph/json-rpc-relay' ;
3131import { EthImpl } from '../../src/lib/eth' ;
3232import { MirrorNodeClient } from '../../src/lib/clients/mirrorNodeClient' ;
3333import { expectUnsupportedMethod } from '../helpers' ;
@@ -337,6 +337,7 @@ describe('Eth calls using MirrorNode', async function () {
337337 } ;
338338
339339 const detailedContractResultNotFound = { "_status" : { "messages" : [ { "message" : "No correlating transaction" } ] } } ;
340+ const timeoutError = { "type" : "Error" , "message" : "timeout of 10000ms exceeded" } ;
340341
341342 const defaultDetailedContractResultsWithNullNullableValues = {
342343 ...defaultDetailedContractResults ,
@@ -1016,6 +1017,51 @@ describe('Eth calls using MirrorNode', async function () {
10161017 expect ( result . length ) . to . eq ( 0 ) ;
10171018 } ) ;
10181019
1020+ it ( 'one of contract results details timeouts and throws the expected error' , async function ( ) {
1021+ mock . onGet ( `contracts/results/logs` ) . reply ( 200 , defaultLogs ) ;
1022+ mock . onGet ( `contracts/${ contractId1 } /results/${ contractTimestamp1 } ` ) . reply ( 200 , defaultDetailedContractResults ) ;
1023+ mock . onGet ( `contracts/${ contractId1 } /results/${ contractTimestamp2 } ` ) . reply ( 567 , timeoutError ) ;
1024+ mock . onGet ( `contracts/${ contractId2 } /results/${ contractTimestamp2 } ` ) . reply ( 200 , defaultDetailedContractResults3 ) ;
1025+
1026+ try {
1027+ const result = await ethImpl . getLogs ( null , null , null , null , null ) ;
1028+ expect ( true ) . to . eq ( false ) ;
1029+ } catch ( error : any ) {
1030+ expect ( error . statusCode ) . to . equal ( MirrorNodeClientError . statusCodes . TIMEOUT ) ;
1031+ }
1032+ } ) ;
1033+
1034+ it ( 'blockHash filter timeouts and throws the expected error' , async function ( ) {
1035+ const filteredLogs = {
1036+ logs : [ defaultLogs . logs [ 0 ] , defaultLogs . logs [ 1 ] ]
1037+ } ;
1038+
1039+ mock . onGet ( `contracts/results/logs` ) . reply ( 200 , defaultLogs ) ;
1040+ mock . onGet ( `contracts/${ contractId1 } /results/${ contractTimestamp1 } ` ) . reply ( 200 , defaultDetailedContractResults ) ;
1041+ mock . onGet ( `contracts/results/logs?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } ` ) . reply ( 200 , filteredLogs ) ;
1042+ mock . onGet ( `blocks/${ blockHash } ` ) . reply ( 567 , timeoutError ) ;
1043+
1044+ try {
1045+ const result = await ethImpl . getLogs ( blockHash , null , null , null , null ) ;
1046+ expect ( true ) . to . eq ( false ) ;
1047+ } catch ( error : any ) {
1048+ expect ( error . statusCode ) . to . equal ( MirrorNodeClientError . statusCodes . TIMEOUT ) ;
1049+ }
1050+ } ) ;
1051+
1052+ it ( 'address filter timeouts and throws the expected error' , async function ( ) {
1053+ mock . onGet ( `contracts/${ contractId1 } /results/${ contractTimestamp1 } ` ) . reply ( 200 , defaultDetailedContractResults ) ;
1054+ mock . onGet ( `contracts/${ contractId1 } /results/${ contractTimestamp2 } ` ) . reply ( 200 , defaultDetailedContractResults2 ) ;
1055+ mock . onGet ( `contracts/${ contractAddress1 } /results/logs` ) . reply ( 567 , timeoutError ) ;
1056+
1057+ try {
1058+ const result = await ethImpl . getLogs ( null , null , null , contractAddress1 , null ) ;
1059+ expect ( true ) . to . eq ( false ) ;
1060+ } catch ( error : any ) {
1061+ expect ( error . statusCode ) . to . equal ( MirrorNodeClientError . statusCodes . TIMEOUT ) ;
1062+ }
1063+ } ) ;
1064+
10191065 it ( 'error when retrieving logs' , async function ( ) {
10201066 mock . onGet ( `contracts/results/logs` ) . reply ( 400 , { "_status" : { "messages" : [ { "message" : "Mocked error" } ] } } ) ;
10211067 const result = await ethImpl . getLogs ( null , null , null , null , null ) ;
0 commit comments