@@ -284,7 +284,7 @@ describe('Debug API Test Suite', async function () {
284
284
} ) ;
285
285
286
286
this . beforeEach ( ( ) => {
287
- cacheService . clear ( requestDetails ) ;
287
+ cacheService . clear ( ) ;
288
288
} ) ;
289
289
290
290
describe ( 'debug_traceTransaction' , async function ( ) {
@@ -640,6 +640,81 @@ describe('Debug API Test Suite', async function () {
640
640
expect ( address ) . to . eq ( accountAddress ) ;
641
641
} ) ;
642
642
} ) ;
643
+
644
+ describe ( 'formatActionsResult with CREATE actions' , async function ( ) {
645
+ it ( 'should handle CREATE action with to=null without making MN lookup' , async function ( ) {
646
+ const createActionWithNullTo = {
647
+ actions : [
648
+ {
649
+ call_depth : 0 ,
650
+ call_operation_type : 'CREATE' ,
651
+ call_type : 'CREATE' ,
652
+ caller : '0.0.1016' ,
653
+ caller_type : 'ACCOUNT' ,
654
+ from : '0x00000000000000000000000000000000000003f8' ,
655
+ gas : 247000 ,
656
+ gas_used : 77324 ,
657
+ index : 0 ,
658
+ input : '0x608060405234801561001057600080fd5b50' ,
659
+ recipient : '0.0.1033' ,
660
+ recipient_type : 'CONTRACT' ,
661
+ result_data : '0x' ,
662
+ result_data_type : 'OUTPUT' ,
663
+ timestamp : '1696438011.462526383' ,
664
+ to : null , // This should not trigger MN lookup
665
+ value : 0 ,
666
+ } ,
667
+ ] ,
668
+ } ;
669
+
670
+ restMock . onGet ( SENDER_BY_ADDRESS ) . reply ( 200 , JSON . stringify ( accountsResult ) ) ;
671
+
672
+ const result = await debugService . formatActionsResult ( createActionWithNullTo . actions , requestDetails ) ;
673
+
674
+ expect ( result ) . to . be . an ( 'array' ) . with . lengthOf ( 1 ) ;
675
+ expect ( result [ 0 ] ) . to . have . property ( 'type' , 'CREATE' ) ;
676
+ expect ( result [ 0 ] ) . to . have . property ( 'from' , '0xc37f417fa09933335240fca72dd257bfbde9c275' ) ;
677
+ expect ( result [ 0 ] ) . to . have . property ( 'to' , null ) ;
678
+ expect ( result [ 0 ] ) . to . have . property ( 'input' , '0x608060405234801561001057600080fd5b50' ) ;
679
+ } ) ;
680
+
681
+ it ( 'should handle CREATE action with to=null and skip getContract call' , async function ( ) {
682
+ const createActionWithNullTo = {
683
+ actions : [
684
+ {
685
+ call_depth : 0 ,
686
+ call_operation_type : 'CREATE' ,
687
+ call_type : 'CREATE' ,
688
+ caller : '0.0.1016' ,
689
+ caller_type : 'ACCOUNT' ,
690
+ from : '0x00000000000000000000000000000000000003f8' ,
691
+ gas : 247000 ,
692
+ gas_used : 77324 ,
693
+ index : 1 , // Non-zero index to test getContract path
694
+ input : '0x608060405234801561001057600080fd5b50' ,
695
+ recipient : '0.0.1033' ,
696
+ recipient_type : 'CONTRACT' ,
697
+ result_data : '0x' ,
698
+ result_data_type : 'OUTPUT' ,
699
+ timestamp : '1696438011.462526383' ,
700
+ to : null , // Should skip getContract call
701
+ value : 0 ,
702
+ } ,
703
+ ] ,
704
+ } ;
705
+
706
+ restMock . onGet ( SENDER_BY_ADDRESS ) . reply ( 200 , JSON . stringify ( accountsResult ) ) ;
707
+ // No mock for getContract call - should not be called
708
+
709
+ const result = await debugService . formatActionsResult ( createActionWithNullTo . actions , requestDetails ) ;
710
+
711
+ expect ( result ) . to . be . an ( 'array' ) . with . lengthOf ( 1 ) ;
712
+ expect ( result [ 0 ] ) . to . have . property ( 'type' , 'CREATE' ) ;
713
+ expect ( result [ 0 ] ) . to . have . property ( 'to' , null ) ;
714
+ expect ( result [ 0 ] ) . to . have . property ( 'input' , '0x608060405234801561001057600080fd5b50' ) ;
715
+ expect ( result [ 0 ] ) . to . have . property ( 'output' , '0x' ) ;
716
+ } ) ;
717
+ } ) ;
643
718
} ) ;
644
719
} ) ;
645
720
} ) ;
@@ -710,7 +785,7 @@ describe('Debug API Test Suite', async function () {
710
785
sinon . restore ( ) ;
711
786
restMock . reset ( ) ;
712
787
web3Mock . reset ( ) ;
713
- cacheService . clear ( requestDetails ) ;
788
+ cacheService . clear ( ) ;
714
789
} ) ;
715
790
716
791
withOverriddenEnvsInMochaTest ( { DEBUG_API_ENABLED : undefined } , ( ) => {
@@ -999,7 +1074,7 @@ describe('Debug API Test Suite', async function () {
999
1074
sinon . restore ( ) ;
1000
1075
restMock . reset ( ) ;
1001
1076
web3Mock . reset ( ) ;
1002
- cacheService . clear ( requestDetails ) ;
1077
+ cacheService . clear ( ) ;
1003
1078
} ) ;
1004
1079
1005
1080
withOverriddenEnvsInMochaTest ( { DEBUG_API_ENABLED : true } , ( ) => {
0 commit comments