@@ -965,6 +965,19 @@ describe('Eth calls using MirrorNode', async function () {
965965 expect ( result . to ) . equal ( contractAddress1 ) ;
966966 } ) ;
967967
968+ it ( 'eth_getTransactionByBlockNumberAndIndex with null amount' , async function ( ) {
969+ // mirror node request mocks
970+ mock . onGet ( `contracts/results?block.number=${ defaultBlock . number } &transaction.index=${ defaultBlock . count } &limit=100&order=asc` ) . reply ( 200 , defaultContractResults ) ;
971+ mock . onGet ( `contracts/${ contractAddress1 } /results/${ contractTimestamp1 } ` ) . reply ( 200 , { ...defaultDetailedContractResults , amount : null } ) ;
972+
973+ const result = await ethImpl . getTransactionByBlockNumberAndIndex ( EthImpl . numberTo0x ( defaultBlock . number ) , EthImpl . numberTo0x ( defaultBlock . count ) ) ;
974+ expect ( result ) . to . exist ;
975+ if ( result == null ) return ;
976+
977+ // verify aggregated info
978+ expect ( result . value ) . equal ( "0x0" ) ;
979+ } ) ;
980+
968981 it ( 'eth_getTransactionByBlockNumberAndIndex with no contract result match' , async function ( ) {
969982 mock . onGet ( `contracts/results?block.number=${ defaultBlock . number } &transaction.index=${ defaultBlock . count } &limit=100&order=asc` ) . reply ( 400 , {
970983 '_status' : {
@@ -1171,7 +1184,7 @@ describe('Eth calls using MirrorNode', async function () {
11711184 balance : defBalance
11721185 }
11731186 } ) ;
1174-
1187+
11751188 const resBalance = await ethImpl . getBalance ( contractAddress1 , blockNumber ) ;
11761189 expect ( resBalance ) . to . equal ( defHexBalance ) ;
11771190 } ) ;
@@ -1558,7 +1571,7 @@ describe('Eth calls using MirrorNode', async function () {
15581571 } ;
15591572
15601573 mock . onGet ( "blocks?limit=1&order=desc" ) . reply ( 200 , { blocks : [ defaultBlock ] } ) ;
1561-
1574+
15621575 mock . onGet ( `contracts/results/logs?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } &limit=2&order=asc` ) . replyOnce ( 200 , filteredLogs )
15631576 . onGet ( 'contracts/results/logs?limit=2&order=desc×tamp=lte:1668432962.375200975&index=lt:0' ) . replyOnce ( 200 , filteredLogsNext ) ;
15641577
@@ -2691,6 +2704,24 @@ describe('Eth', async function () {
26912704 expect ( result . gas ) . to . eq ( '0x0' ) ;
26922705 } ) ;
26932706
2707+ it ( 'handles transactions with null amount' , async function ( ) {
2708+ // mirror node request mocks
2709+ const detailedResultsWithNullNullableValues = {
2710+ ...defaultDetailedContractResultByHash ,
2711+ amount : null
2712+ } ;
2713+
2714+ mock . onGet ( `contracts/results/${ defaultTxHash } ` ) . reply ( 200 , detailedResultsWithNullNullableValues ) ;
2715+ mock . onGet ( `accounts/${ defaultFromLongZeroAddress } ` ) . reply ( 200 , {
2716+ evm_address : `${ defaultTransaction . from } `
2717+ } ) ;
2718+ const result = await ethImpl . getTransactionByHash ( defaultTxHash ) ;
2719+ if ( result == null ) return ;
2720+
2721+ expect ( result ) . to . exist ;
2722+ expect ( result . value ) . to . eq ( '0x0' ) ;
2723+ } ) ;
2724+
26942725 it ( 'returns reverted transactions' , async function ( ) {
26952726 mock . onGet ( `contracts/results/${ defaultTxHash } ` ) . reply ( 200 , defaultDetailedContractResultByHashReverted ) ;
26962727 mock . onGet ( `accounts/${ defaultFromLongZeroAddress } ` ) . reply ( 200 , {
@@ -2721,7 +2752,7 @@ describe('Eth', async function () {
27212752 expect ( result . type ) . to . eq ( EthImpl . numberTo0x ( defaultTransaction . type ) ) ;
27222753 expect ( result . v ) . to . eq ( EthImpl . numberTo0x ( defaultTransaction . v ) ) ;
27232754 expect ( result . value ) . to . eq ( defaultTransaction . value ) ;
2724- } )
2755+ } ) ;
27252756
27262757 it ( 'throws error for reverted transactions when DEV_MODE=true' , async function ( ) {
27272758 const initialDevModeValue = process . env . DEV_MODE ;
@@ -2741,6 +2772,6 @@ describe('Eth', async function () {
27412772 }
27422773
27432774 process . env . DEV_MODE = initialDevModeValue ;
2744- } )
2775+ } ) ;
27452776 } ) ;
27462777} ) ;
0 commit comments