@@ -5,7 +5,8 @@ import MockAdapter from 'axios-mock-adapter';
5
5
import { expect , use } from 'chai' ;
6
6
import chaiAsPromised from 'chai-as-promised' ;
7
7
import pino from 'pino' ;
8
- import { register , Registry } from 'prom-client' ;
8
+ import { Registry } from 'prom-client' ;
9
+ import sinon from 'sinon' ;
9
10
10
11
import { nanOrNumberTo0x , nullableNumberTo0x , numberTo0x , toHash32 } from '../../src/formatters' ;
11
12
import { MirrorNodeClient } from '../../src/lib/clients' ;
@@ -101,7 +102,13 @@ describe('eth_getBlockBy', async function () {
101
102
overrideEnvsInMochaDescribe ( { ETH_FEE_HISTORY_FIXED : false } ) ;
102
103
103
104
this . beforeAll ( async ( ) => {
104
- cacheService = new CacheService ( logger , registry ) ;
105
+ const redisClientMock = {
106
+ connect : sinon . stub ( ) . resolves ( true ) ,
107
+ on : sinon . stub ( ) ,
108
+ eval : sinon . stub ( ) ,
109
+ quit : sinon . stub ( ) . resolves ( true ) ,
110
+ } as any ;
111
+ cacheService = new CacheService ( logger , registry , new Set ( ) , redisClientMock as any ) ;
105
112
106
113
// @ts -ignore
107
114
mirrorNodeInstance = new MirrorNodeClient (
@@ -119,7 +126,7 @@ describe('eth_getBlockBy', async function () {
119
126
} ) ;
120
127
121
128
this . beforeEach ( async ( ) => {
122
- await cacheService . clear ( requestDetails ) ;
129
+ await cacheService . clear ( ) ;
123
130
restMock . reset ( ) ;
124
131
} ) ;
125
132
@@ -149,7 +156,7 @@ describe('eth_getBlockBy', async function () {
149
156
150
157
it ( 'populateSyntheticTransactions with no dupes in empty transactionHashes' , async function ( ) {
151
158
const initHashes = [ ] ;
152
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , initHashes , requestDetails ) ;
159
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , initHashes ) ;
153
160
expect ( initHashes . length ) . to . equal ( defaultLogs1 . length ) ;
154
161
expect ( initHashes [ 0 ] ) . to . equal ( modelLog1 . transactionHash ) ;
155
162
expect ( initHashes [ 1 ] ) . to . equal ( modelLog2 . transactionHash ) ;
@@ -159,7 +166,7 @@ describe('eth_getBlockBy', async function () {
159
166
it ( 'populateSyntheticTransactions with no dupes in non empty transactionHashes' , async function ( ) {
160
167
const initHashes = [ 'txHash1' , 'txHash2' ] ;
161
168
const txHashes = initHashes . slice ( ) ;
162
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txHashes , requestDetails ) ;
169
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txHashes ) ;
163
170
expect ( txHashes . length ) . to . equal ( initHashes . length + defaultLogs1 . length ) ;
164
171
expect ( txHashes [ initHashes . length + 0 ] ) . to . equal ( modelLog1 . transactionHash ) ;
165
172
expect ( txHashes [ initHashes . length + 1 ] ) . to . equal ( modelLog2 . transactionHash ) ;
@@ -169,7 +176,7 @@ describe('eth_getBlockBy', async function () {
169
176
it ( 'populateSyntheticTransactions with 1 transaction dupes in transactionHashes' , async function ( ) {
170
177
const initHashes = [ modelLog2 . transactionHash ] ;
171
178
const txHashes = initHashes . slice ( ) ;
172
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txHashes , requestDetails ) ;
179
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txHashes ) ;
173
180
expect ( txHashes . length ) . to . equal ( referenceLogs . length ) ;
174
181
expect ( txHashes [ 0 ] ) . to . equal ( contractHash2 ) ;
175
182
expect ( txHashes [ 1 ] ) . to . equal ( modelLog1 . transactionHash ) ;
@@ -179,7 +186,7 @@ describe('eth_getBlockBy', async function () {
179
186
it ( 'populateSyntheticTransactions with all dupes in transactionHashes' , async function ( ) {
180
187
const initHashes = [ modelLog1 . transactionHash , modelLog2 . transactionHash , modelLog3 . transactionHash ] ;
181
188
const txHashes = initHashes . slice ( ) ;
182
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txHashes , requestDetails ) ;
189
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txHashes ) ;
183
190
expect ( txHashes . length ) . to . equal ( referenceLogs . length ) ;
184
191
expect ( txHashes [ 0 ] ) . to . equal ( modelLog1 . transactionHash ) ;
185
192
expect ( txHashes [ 1 ] ) . to . equal ( modelLog2 . transactionHash ) ;
@@ -215,7 +222,7 @@ describe('eth_getBlockBy', async function () {
215
222
const showDetails = true ;
216
223
it ( 'populateSyntheticTransactions with no dupes in empty txObjects' , async function ( ) {
217
224
const initTxObjects : Transaction [ ] = [ ] ;
218
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , initTxObjects , requestDetails ) ;
225
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , initTxObjects ) ;
219
226
expect ( initTxObjects . length ) . to . equal ( defaultLogs1 . length ) ;
220
227
expect ( initTxObjects [ 0 ] . hash ) . to . equal ( modelLog1 . transactionHash ) ;
221
228
expect ( initTxObjects [ 1 ] . hash ) . to . equal ( modelLog2 . transactionHash ) ;
@@ -225,7 +232,7 @@ describe('eth_getBlockBy', async function () {
225
232
it ( 'populateSyntheticTransactions with no dupes in non empty txObjects' , async function ( ) {
226
233
const initTxObjects = [ getTransactionModel ( 'txHash1' ) , getTransactionModel ( 'txHash2' ) ] ;
227
234
const txObjects = initTxObjects . slice ( ) ;
228
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txObjects , requestDetails ) ;
235
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txObjects ) ;
229
236
expect ( txObjects . length ) . to . equal ( initTxObjects . length + defaultLogs1 . length ) ;
230
237
expect ( txObjects [ initTxObjects . length + 0 ] . hash ) . to . equal ( modelLog1 . transactionHash ) ;
231
238
expect ( txObjects [ initTxObjects . length + 1 ] . hash ) . to . equal ( modelLog2 . transactionHash ) ;
@@ -235,7 +242,7 @@ describe('eth_getBlockBy', async function () {
235
242
it ( 'populateSyntheticTransactions with 1 transaction dupes in txObjects' , async function ( ) {
236
243
const initTxObjects = [ getTransactionModel ( modelLog2 . transactionHash ) ] ;
237
244
const txObjects = initTxObjects . slice ( ) ;
238
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txObjects , requestDetails ) ;
245
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txObjects ) ;
239
246
expect ( txObjects . length ) . to . equal ( referenceLogs . length ) ;
240
247
expect ( txObjects [ 0 ] . hash ) . to . equal ( contractHash2 ) ;
241
248
expect ( txObjects [ 1 ] . hash ) . to . equal ( modelLog1 . transactionHash ) ;
@@ -249,7 +256,7 @@ describe('eth_getBlockBy', async function () {
249
256
getTransactionModel ( modelLog3 . transactionHash ) ,
250
257
] ;
251
258
const txObjects = initTxObjects . slice ( ) ;
252
- blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txObjects , requestDetails ) ;
259
+ blockService [ 'populateSyntheticTransactions' ] ( showDetails , referenceLogs , txObjects ) ;
253
260
expect ( txObjects . length ) . to . equal ( referenceLogs . length ) ;
254
261
expect ( txObjects [ 0 ] . hash ) . to . equal ( modelLog1 . transactionHash ) ;
255
262
expect ( txObjects [ 1 ] . hash ) . to . equal ( modelLog2 . transactionHash ) ;
@@ -262,12 +269,7 @@ describe('eth_getBlockBy', async function () {
262
269
const initTxObjects = [ tx1 , tx2 ] ;
263
270
264
271
const txObjects = initTxObjects . slice ( ) ;
265
- const returnedTxObjects = blockService [ 'populateSyntheticTransactions' ] (
266
- true ,
267
- referenceLogs ,
268
- txObjects ,
269
- requestDetails ,
270
- ) ;
272
+ const returnedTxObjects = blockService [ 'populateSyntheticTransactions' ] ( true , referenceLogs , txObjects ) ;
271
273
272
274
// Should only have one object with modelLog1.transactionHash
273
275
const count = returnedTxObjects . filter ( ( tx ) => ( tx as Transaction ) . hash === modelLog1 . transactionHash ) . length ;
0 commit comments