@@ -80,6 +80,7 @@ let restMock: MockAdapter, web3Mock: MockAdapter;
8080let mirrorNodeInstance : MirrorNodeClient ;
8181let sdkClientStub ;
8282let cache ;
83+ let mirrorNodeCache ;
8384
8485describe ( 'Eth calls using MirrorNode' , async function ( ) {
8586 this . timeout ( 10000 ) ;
@@ -91,6 +92,9 @@ describe('Eth calls using MirrorNode', async function () {
9192 // @ts -ignore
9293 mirrorNodeInstance = new MirrorNodeClient ( process . env . MIRROR_NODE_URL , logger . child ( { name : `mirror-node` } ) , registry ) ;
9394
95+ // @ts -ignore
96+ mirrorNodeCache = mirrorNodeInstance . cache ;
97+
9498 // @ts -ignore
9599 restMock = new MockAdapter ( mirrorNodeInstance . getMirrorNodeRestInstance ( ) , { onNoMatch : "throwException" } ) ;
96100
@@ -792,6 +796,7 @@ describe('Eth calls using MirrorNode', async function () {
792796 } ) ;
793797
794798 it ( 'eth_getBlockByNumber with zero transactions' , async function ( ) {
799+ mirrorNodeCache . clear ( ) ;
795800 // mirror node request mocks
796801 restMock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 200 , { ...defaultBlock , gas_used : 0 } ) ;
797802 restMock . onGet ( `contracts/results?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } &limit=100&order=asc` ) . reply ( 200 , { 'results' : [ ] } ) ;
@@ -814,6 +819,7 @@ describe('Eth calls using MirrorNode', async function () {
814819 } ) ;
815820
816821 it ( 'eth_getBlockByNumber with match and details' , async function ( ) {
822+ mirrorNodeCache . clear ( ) ;
817823 const resultWithNullGasUsed = {
818824 ...defaultDetailedContractResults ,
819825 gas_used : null
@@ -844,6 +850,7 @@ describe('Eth calls using MirrorNode', async function () {
844850 } ) ;
845851
846852 it ( 'eth_getBlockByNumber with block match and contract revert' , async function ( ) {
853+ mirrorNodeCache . clear ( ) ;
847854 // mirror node request mocks
848855 restMock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 200 , { ...defaultBlock , gas_used : gasUsed1 } ) ;
849856 restMock . onGet ( `contracts/results?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } &limit=100&order=asc` ) . reply ( 200 , defaultContractResultsRevert ) ;
@@ -866,6 +873,7 @@ describe('Eth calls using MirrorNode', async function () {
866873 } ) ;
867874
868875 it ( 'eth_getBlockByNumber with no match' , async function ( ) {
876+ mirrorNodeCache . clear ( ) ;
869877 restMock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 400 , {
870878 '_status' : {
871879 'messages' : [
@@ -993,6 +1001,7 @@ describe('Eth calls using MirrorNode', async function () {
9931001 } ) ;
9941002
9951003 it ( 'eth_getBlockByHash with block match and contract revert' , async function ( ) {
1004+ mirrorNodeCache . clear ( ) ;
9961005 // mirror node request mocks
9971006 restMock . onGet ( `blocks/${ blockHash } ` ) . reply ( 200 , { ...defaultBlock , gas_used : gasUsed1 } ) ;
9981007 restMock . onGet ( `contracts/results?timestamp=gte:${ defaultBlock . timestamp . from } ×tamp=lte:${ defaultBlock . timestamp . to } &limit=100&order=asc` ) . reply ( 200 , defaultContractResultsRevert ) ;
@@ -1015,6 +1024,7 @@ describe('Eth calls using MirrorNode', async function () {
10151024 } ) ;
10161025
10171026 it ( 'eth_getBlockByHash with no match' , async function ( ) {
1027+ mirrorNodeCache . clear ( ) ;
10181028 // mirror node request mocks
10191029 restMock . onGet ( `blocks/${ blockHash } ` ) . reply ( 400 , {
10201030 '_status' : {
@@ -1056,6 +1066,7 @@ describe('Eth calls using MirrorNode', async function () {
10561066 } ) ;
10571067
10581068 it ( 'eth_getBlockTransactionCountByNumber with no match' , async function ( ) {
1069+ mirrorNodeCache . clear ( ) ;
10591070 restMock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 400 , {
10601071 '_status' : {
10611072 'messages' : [
@@ -1113,6 +1124,7 @@ describe('Eth calls using MirrorNode', async function () {
11131124 } ) ;
11141125
11151126 it ( 'eth_getBlockTransactionCountByHash with no match' , async function ( ) {
1127+ mirrorNodeCache . clear ( ) ;
11161128 // mirror node request mocks
11171129 restMock . onGet ( `blocks/${ blockHash } ` ) . reply ( 400 , {
11181130 '_status' : {
@@ -1553,6 +1565,7 @@ describe('Eth calls using MirrorNode', async function () {
15531565 } ) ;
15541566
15551567 beforeEach ( async ( ) => {
1568+ mirrorNodeCache . clear ( ) ;
15561569 restMock . onGet ( `blocks?limit=1&order=desc` ) . reply ( 200 , { blocks : [ latestBlock ] } ) ;
15571570 restMock . onGet ( `blocks/3` ) . reply ( 200 , defaultBlock ) ;
15581571 restMock . onGet ( `blocks/0` ) . reply ( 200 , blockZero ) ;
@@ -2355,6 +2368,7 @@ describe('Eth calls using MirrorNode', async function () {
23552368 } ) ;
23562369
23572370 it ( 'with non-existing toBlock filter' , async function ( ) {
2371+ mirrorNodeCache . clear ( ) ;
23582372 const filteredLogs = {
23592373 logs : [ defaultLogs . logs [ 0 ] ]
23602374 } ;
@@ -2493,6 +2507,7 @@ describe('Eth calls using MirrorNode', async function () {
24932507 } ) ;
24942508
24952509 it ( 'with topics and blocks filter' , async function ( ) {
2510+ mirrorNodeCache . clear ( ) ;
24962511 const filteredLogs = {
24972512 logs : [ defaultLogs . logs [ 0 ] , defaultLogs . logs [ 1 ] ]
24982513 } ;
@@ -3537,7 +3552,7 @@ describe('Eth calls using MirrorNode', async function () {
35373552 } ) ;
35383553
35393554 it ( 'eth_getStorageAt should throw a predefined RESOURCE_NOT_FOUND when block not found' , async function ( ) {
3540-
3555+ mirrorNodeCache . clear ( ) ;
35413556 let hasError = false ;
35423557 try {
35433558 restMock . onGet ( `blocks/${ blockNumber } ` ) . reply ( 200 , null ) ;
0 commit comments