@@ -54,6 +54,7 @@ const validateHash = (hash: string, len?: number) => {
5454} ;
5555
5656const verifyBlockConstants = ( block : Block ) => {
57+ expect ( block . gasLimit ) . equal ( EthImpl . numberTo0x ( 15000000 ) ) ;
5758 expect ( block . baseFeePerGas ) . equal ( '0x84b6a5c400' ) ;
5859 expect ( block . difficulty ) . equal ( EthImpl . zeroHex ) ;
5960 expect ( block . extraData ) . equal ( EthImpl . emptyHex ) ;
@@ -115,7 +116,9 @@ describe('Eth calls using MirrorNode', async function () {
115116 const gasUsed2 = 800000 ;
116117 const maxGasLimit = 250000 ;
117118 const maxGasLimitHex = EthImpl . numberTo0x ( maxGasLimit ) ;
118- const contractCallData = "0xef641f44"
119+ const contractCallData = "0xef641f44" ;
120+ const blockTimestamp = '1651560386' ;
121+ const blockTimestampHex = EthImpl . numberTo0x ( Number ( blockTimestamp ) ) ;
119122 const firstTransactionTimestampSeconds = '1653077547' ;
120123 const firstTransactionTimestampSecondsHex = EthImpl . numberTo0x ( Number ( firstTransactionTimestampSeconds ) ) ;
121124 const contractAddress1 = '0x000000000000000000000000000000000000055f' ;
@@ -134,16 +137,18 @@ describe('Eth calls using MirrorNode', async function () {
134137
135138 const defaultBlock = {
136139 'count' : blockTransactionCount ,
137- 'hapi_version' : '0.27.0 ' ,
140+ 'hapi_version' : '0.28.1 ' ,
138141 'hash' : blockHash ,
139142 'name' : '2022-05-03T06_46_26.060890949Z.rcd' ,
140143 'number' : blockNumber ,
141144 'previous_hash' : '0xf7d6481f659c866c35391ee230c374f163642ebf13a5e604e04a95a9ca48a298dc2dfa10f51bcbaab8ae23bc6d662a0b' ,
142145 'size' : null ,
143146 'timestamp' : {
144- 'from' : '1651560386 .060890949' ,
147+ 'from' : ` ${ blockTimestamp } .060890949` ,
145148 'to' : '1651560389.060890949'
146- }
149+ } ,
150+ 'gas_used' : gasUsed1 + gasUsed2 ,
151+ 'logs_bloom' : '0x'
147152 } ;
148153
149154
@@ -435,10 +440,9 @@ describe('Eth calls using MirrorNode', async function () {
435440 // verify aggregated info
436441 expect ( result . hash ) . equal ( blockHashTrimmed ) ;
437442 expect ( result . gasUsed ) . equal ( totalGasUsed ) ;
438- expect ( result . gasLimit ) . equal ( maxGasLimitHex ) ;
439443 expect ( result . number ) . equal ( blockNumberHex ) ;
440444 expect ( result . parentHash ) . equal ( blockHashPreviousTrimmed ) ;
441- expect ( result . timestamp ) . equal ( firstTransactionTimestampSecondsHex ) ;
445+ expect ( result . timestamp ) . equal ( blockTimestampHex ) ;
442446 expect ( result . transactions . length ) . equal ( 2 ) ;
443447 expect ( ( result . transactions [ 0 ] as string ) ) . equal ( contractHash1 ) ;
444448 expect ( ( result . transactions [ 1 ] as string ) ) . equal ( contractHash1 ) ;
@@ -449,7 +453,7 @@ describe('Eth calls using MirrorNode', async function () {
449453
450454 it ( 'eth_getBlockByNumber with zero transactions' , async function ( ) {
451455 // mirror node request mocks
452- mock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 200 , defaultBlock ) ;
456+ mock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 200 , { ... defaultBlock , gas_used : 0 } ) ;
453457 mock . onGet ( `contracts/results?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } ` ) . reply ( 200 , { 'results' : [ ] } ) ;
454458 mock . onGet ( 'network/fees' ) . reply ( 200 , defaultNetworkFees ) ;
455459 const result = await ethImpl . getBlockByNumber ( EthImpl . numberTo0x ( blockNumber ) , false ) ;
@@ -459,10 +463,9 @@ describe('Eth calls using MirrorNode', async function () {
459463 // verify aggregated info
460464 expect ( result . hash ) . equal ( blockHashTrimmed ) ;
461465 expect ( result . gasUsed ) . equal ( '0x0' ) ;
462- expect ( result . gasLimit ) . equal ( '0x0' ) ;
463466 expect ( result . number ) . equal ( blockNumberHex ) ;
464467 expect ( result . parentHash ) . equal ( blockHashPreviousTrimmed ) ;
465- expect ( result . timestamp ) . equal ( '0x0' ) ;
468+ expect ( result . timestamp ) . equal ( blockTimestampHex ) ;
466469 expect ( result . transactions . length ) . equal ( 0 ) ;
467470 expect ( result . transactionsRoot ) . equal ( EthImpl . ethEmptyTrie ) ;
468471
@@ -484,10 +487,9 @@ describe('Eth calls using MirrorNode', async function () {
484487 // verify aggregated info
485488 expect ( result . hash ) . equal ( blockHashTrimmed ) ;
486489 expect ( result . gasUsed ) . equal ( totalGasUsed ) ;
487- expect ( result . gasLimit ) . equal ( maxGasLimitHex ) ;
488490 expect ( result . number ) . equal ( blockNumberHex ) ;
489491 expect ( result . parentHash ) . equal ( blockHashPreviousTrimmed ) ;
490- expect ( result . timestamp ) . equal ( firstTransactionTimestampSecondsHex ) ;
492+ expect ( result . timestamp ) . equal ( blockTimestampHex ) ;
491493 expect ( result . transactions . length ) . equal ( 2 ) ;
492494 expect ( ( result . transactions [ 0 ] as Transaction ) . hash ) . equal ( contractHash1 ) ;
493495 expect ( ( result . transactions [ 1 ] as Transaction ) . hash ) . equal ( contractHash1 ) ;
@@ -498,7 +500,7 @@ describe('Eth calls using MirrorNode', async function () {
498500
499501 it ( 'eth_getBlockByNumber with block match and contract revert' , async function ( ) {
500502 // mirror node request mocks
501- mock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 200 , defaultBlock ) ;
503+ mock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 200 , { ... defaultBlock , gas_used : gasUsed1 } ) ;
502504 mock . onGet ( `contracts/results?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } ` ) . reply ( 200 , defaultContractResultsRevert ) ;
503505 mock . onGet ( 'network/fees' ) . reply ( 200 , defaultNetworkFees ) ;
504506
@@ -509,10 +511,9 @@ describe('Eth calls using MirrorNode', async function () {
509511 // verify aggregated info
510512 expect ( result . hash ) . equal ( blockHashTrimmed ) ;
511513 expect ( result . gasUsed ) . equal ( EthImpl . numberTo0x ( gasUsed1 ) ) ;
512- expect ( result . gasLimit ) . equal ( maxGasLimitHex ) ;
513514 expect ( result . number ) . equal ( blockNumberHex ) ;
514515 expect ( result . parentHash ) . equal ( blockHashPreviousTrimmed ) ;
515- expect ( result . timestamp ) . equal ( firstTransactionTimestampSecondsHex ) ;
516+ expect ( result . timestamp ) . equal ( blockTimestampHex ) ;
516517 expect ( result . transactions . length ) . equal ( 0 ) ;
517518
518519 // verify expected constants
@@ -598,10 +599,9 @@ describe('Eth calls using MirrorNode', async function () {
598599 // verify aggregated info
599600 expect ( result . hash ) . equal ( blockHashTrimmed ) ;
600601 expect ( result . gasUsed ) . equal ( totalGasUsed ) ;
601- expect ( result . gasLimit ) . equal ( maxGasLimitHex ) ;
602602 expect ( result . number ) . equal ( blockNumberHex ) ;
603603 expect ( result . parentHash ) . equal ( blockHashPreviousTrimmed ) ;
604- expect ( result . timestamp ) . equal ( firstTransactionTimestampSecondsHex ) ;
604+ expect ( result . timestamp ) . equal ( blockTimestampHex ) ;
605605 expect ( result . transactions . length ) . equal ( 2 ) ;
606606 expect ( ( result . transactions [ 0 ] as string ) ) . equal ( contractHash1 ) ;
607607 expect ( ( result . transactions [ 1 ] as string ) ) . equal ( contractHash1 ) ;
@@ -625,10 +625,9 @@ describe('Eth calls using MirrorNode', async function () {
625625 // verify aggregated info
626626 expect ( result . hash ) . equal ( blockHashTrimmed ) ;
627627 expect ( result . gasUsed ) . equal ( totalGasUsed ) ;
628- expect ( result . gasLimit ) . equal ( maxGasLimitHex ) ;
629628 expect ( result . number ) . equal ( blockNumberHex ) ;
630629 expect ( result . parentHash ) . equal ( blockHashPreviousTrimmed ) ;
631- expect ( result . timestamp ) . equal ( firstTransactionTimestampSecondsHex ) ;
630+ expect ( result . timestamp ) . equal ( blockTimestampHex ) ;
632631 expect ( result . transactions . length ) . equal ( 2 ) ;
633632 expect ( ( result . transactions [ 0 ] as Transaction ) . hash ) . equal ( contractHash1 ) ;
634633 expect ( ( result . transactions [ 1 ] as Transaction ) . hash ) . equal ( contractHash1 ) ;
@@ -639,7 +638,7 @@ describe('Eth calls using MirrorNode', async function () {
639638
640639 it ( 'eth_getBlockByHash with block match and contract revert' , async function ( ) {
641640 // mirror node request mocks
642- mock . onGet ( `blocks/${ blockHash } ` ) . reply ( 200 , defaultBlock ) ;
641+ mock . onGet ( `blocks/${ blockHash } ` ) . reply ( 200 , { ... defaultBlock , gas_used : gasUsed1 } ) ;
643642 mock . onGet ( `contracts/results?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } ` ) . reply ( 200 , defaultContractResultsRevert ) ;
644643 mock . onGet ( 'network/fees' ) . reply ( 200 , defaultNetworkFees ) ;
645644
@@ -650,10 +649,9 @@ describe('Eth calls using MirrorNode', async function () {
650649 // verify aggregated info
651650 expect ( result . hash ) . equal ( blockHashTrimmed ) ;
652651 expect ( result . gasUsed ) . equal ( EthImpl . numberTo0x ( gasUsed1 ) ) ;
653- expect ( result . gasLimit ) . equal ( maxGasLimitHex ) ;
654652 expect ( result . number ) . equal ( blockNumberHex ) ;
655653 expect ( result . parentHash ) . equal ( blockHashPreviousTrimmed ) ;
656- expect ( result . timestamp ) . equal ( firstTransactionTimestampSecondsHex ) ;
654+ expect ( result . timestamp ) . equal ( blockTimestampHex ) ;
657655 expect ( result . transactions . length ) . equal ( 0 ) ;
658656
659657 // verify expected constants
0 commit comments