@@ -18,13 +18,13 @@ import { EvmAddressHbarSpendingPlanRepository } from '../../src/lib/db/repositor
18
18
import { HbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository' ;
19
19
import { IPAddressHbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository' ;
20
20
import { DebugImpl } from '../../src/lib/debug' ;
21
+ import { CommonService } from '../../src/lib/services' ;
21
22
import { CacheService } from '../../src/lib/services/cacheService/cacheService' ;
22
23
import HAPIService from '../../src/lib/services/hapiService/hapiService' ;
23
24
import { HbarLimitService } from '../../src/lib/services/hbarLimitService' ;
24
25
import { RequestDetails } from '../../src/lib/types' ;
25
26
import RelayAssertions from '../assertions' ;
26
27
import { getQueryParams , withOverriddenEnvsInMochaTest } from '../helpers' ;
27
- import { CommonService } from '../../src/lib/services' ;
28
28
chai . use ( chaiAsPromised ) ;
29
29
30
30
const logger = pino ( { level : 'silent' } ) ;
@@ -622,8 +622,7 @@ describe('Debug API Test Suite', async function () {
622
622
} ) ;
623
623
624
624
withOverriddenEnvsInMochaTest ( { DEBUG_API_ENABLED : true } , ( ) => {
625
- it ( 'should return empty array if block is not found' , async function ( ) {
626
- // Stub CommonService.getHistoricalBlockResponse
625
+ it ( 'should throw RESOURCE_NOT_FOUND if block is not found' , async function ( ) {
627
626
const getHistoricalBlockResponseStub = sinon . stub ( ) . resolves ( null ) ;
628
627
sinon . stub ( CommonService . prototype , 'getHistoricalBlockResponse' ) . callsFake ( getHistoricalBlockResponseStub ) ;
629
628
@@ -641,11 +640,9 @@ describe('Debug API Test Suite', async function () {
641
640
} ) ;
642
641
643
642
it ( 'should return empty array if no contract results are found for the block' , async function ( ) {
644
- // Stub CommonService.getHistoricalBlockResponse
645
643
const getHistoricalBlockResponseStub = sinon . stub ( ) . resolves ( blockResponse ) ;
646
644
sinon . stub ( CommonService . prototype , 'getHistoricalBlockResponse' ) . callsFake ( getHistoricalBlockResponseStub ) ;
647
645
648
- // Stub MirrorNodeClient.getContractResultWithRetry
649
646
sinon . stub ( mirrorNodeInstance , 'getContractResultWithRetry' ) . resolves ( [ ] ) ;
650
647
651
648
const result = await debugService . traceBlockByNumber (
@@ -660,11 +657,9 @@ describe('Debug API Test Suite', async function () {
660
657
it ( 'should return cached result if available' , async function ( ) {
661
658
const cachedResult = [ { txHash : '0xabc123' , result : callTracerResult1 } ] ;
662
659
663
- // Stub CommonService.getHistoricalBlockResponse
664
660
const getHistoricalBlockResponseStub = sinon . stub ( ) . resolves ( blockResponse ) ;
665
661
sinon . stub ( CommonService . prototype , 'getHistoricalBlockResponse' ) . callsFake ( getHistoricalBlockResponseStub ) ;
666
662
667
- // Stub CacheService.getAsync
668
663
sinon . stub ( cacheService , 'getAsync' ) . resolves ( cachedResult ) ;
669
664
670
665
const result = await debugService . traceBlockByNumber (
@@ -678,11 +673,9 @@ describe('Debug API Test Suite', async function () {
678
673
679
674
describe ( 'with CallTracer' , async function ( ) {
680
675
beforeEach ( ( ) => {
681
- // Stub CommonService.getHistoricalBlockResponse
682
676
const getHistoricalBlockResponseStub = sinon . stub ( ) . resolves ( blockResponse ) ;
683
677
sinon . stub ( CommonService . prototype , 'getHistoricalBlockResponse' ) . callsFake ( getHistoricalBlockResponseStub ) ;
684
678
685
- // Stub CacheService methods
686
679
sinon . stub ( cacheService , 'getAsync' ) . resolves ( null ) ;
687
680
sinon . stub ( cacheService , 'set' ) . resolves ( ) ;
688
681
} ) ;
@@ -726,11 +719,9 @@ describe('Debug API Test Suite', async function () {
726
719
727
720
describe ( 'with PrestateTracer' , async function ( ) {
728
721
beforeEach ( ( ) => {
729
- // Stub CommonService.getHistoricalBlockResponse
730
722
const getHistoricalBlockResponseStub = sinon . stub ( ) . resolves ( blockResponse ) ;
731
723
sinon . stub ( CommonService . prototype , 'getHistoricalBlockResponse' ) . callsFake ( getHistoricalBlockResponseStub ) ;
732
724
733
- // Stub CacheService methods
734
725
sinon . stub ( cacheService , 'getAsync' ) . resolves ( null ) ;
735
726
sinon . stub ( cacheService , 'set' ) . resolves ( ) ;
736
727
} ) ;
@@ -760,14 +751,11 @@ describe('Debug API Test Suite', async function () {
760
751
} ) ;
761
752
762
753
it ( 'should handle error scenarios' , async function ( ) {
763
- // Create a proper JsonRpcError
764
754
const jsonRpcError = predefined . INTERNAL_ERROR ( 'Test error' ) ;
765
755
766
- // Stub CommonService.getHistoricalBlockResponse to throw error
767
756
const getHistoricalBlockResponseStub = sinon . stub ( ) . throws ( jsonRpcError ) ;
768
757
sinon . stub ( CommonService . prototype , 'getHistoricalBlockResponse' ) . callsFake ( getHistoricalBlockResponseStub ) ;
769
758
770
- // Stub CommonService.genericErrorHandler to return the error
771
759
const genericErrorHandlerStub = sinon . stub ( ) . returns ( jsonRpcError ) ;
772
760
sinon . stub ( CommonService . prototype , 'genericErrorHandler' ) . callsFake ( genericErrorHandlerStub ) ;
773
761
0 commit comments