@@ -204,6 +204,73 @@ describe('Eth calls using MirrorNode', async function () {
204204 }
205205 } ;
206206
207+ const defaultLogTopics = [
208+ "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" ,
209+ "0x0000000000000000000000000000000000000000000000000000000000000000" ,
210+ "0x000000000000000000000000000000000000000000000000000000000208fa13" ,
211+ "0x0000000000000000000000000000000000000000000000000000000000000005"
212+ ] ;
213+
214+
215+ const logBloom1 = '0x1111' ;
216+ const logBloom2 = '0x2222' ;
217+ const logBloom3 = '0x3333' ;
218+ const logBloom4 = '0x4444' ;
219+
220+ const defaultLogs1 = [
221+ {
222+ "address" : "0x0000000000000000000000000000000002131951" ,
223+ "bloom" : logBloom1 ,
224+ "contract_id" : contractId1 ,
225+ "data" : "0x" ,
226+ "index" : 0 ,
227+ "topics" : defaultLogTopics ,
228+ "root_contract_id" : "0.0.34806097" ,
229+ "timestamp" : contractTimestamp1
230+ } ,
231+ {
232+ "address" : "0x0000000000000000000000000000000002131951" ,
233+ "bloom" : logBloom2 ,
234+ "contract_id" : contractId1 ,
235+ "data" : "0x" ,
236+ "index" : 1 ,
237+ "topics" : defaultLogTopics ,
238+ "root_contract_id" : "0.0.34806097" ,
239+ "timestamp" : contractTimestamp1
240+ }
241+ ] ;
242+
243+ const defaultLogs2 = [
244+ {
245+ "address" : "0x0000000000000000000000000000000002131951" ,
246+ "bloom" : logBloom3 ,
247+ "contract_id" : contractId1 ,
248+ "data" : "0x" ,
249+ "index" : 0 ,
250+ "topics" : [ ] ,
251+ "root_contract_id" : "0.0.34806097" ,
252+ "timestamp" : contractTimestamp2
253+ }
254+ ] ;
255+
256+ const defaultLogs3 = [
257+ {
258+ "address" : "0x0000000000000000000000000000000002131951" ,
259+ "bloom" : logBloom4 ,
260+ "contract_id" : contractId2 ,
261+ "data" : "0x" ,
262+ "index" : 0 ,
263+ "topics" : [ ] ,
264+ "root_contract_id" : "0.0.34806097" ,
265+ "timestamp" : contractTimestamp3
266+ }
267+ ] ;
268+
269+ const defaultLogsList = defaultLogs1 . concat ( defaultLogs2 ) . concat ( defaultLogs3 ) ;
270+ const defaultLogs = {
271+ "logs" : defaultLogsList
272+ } ;
273+
207274 const defaultDetailedContractResults = {
208275 'access_list' : '0x' ,
209276 'amount' : 2000000000 ,
@@ -222,21 +289,7 @@ describe('Eth calls using MirrorNode', async function () {
222289 'gas_price' : '0x4a817c80' ,
223290 'gas_used' : 123 ,
224291 'hash' : contractHash1 ,
225- 'logs' : [
226- {
227- 'address' : contractAddress1 ,
228- 'bloom' : '0x0123' ,
229- 'contract_id' : contractId1 ,
230- 'data' : '0x0123' ,
231- 'index' : 0 ,
232- 'topics' : [
233- '0x97c1fc0a6ed5551bc831571325e9bdb365d06803100dc20648640ba24ce69750' ,
234- '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' ,
235- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' ,
236- '0xe8d47b56e8cdfa95f871b19d4f50a857217c44a95502b0811a350fec1500dd67'
237- ]
238- } ,
239- ] ,
292+ 'logs' : defaultLogs1 ,
240293 'max_fee_per_gas' : '0x' ,
241294 'max_priority_fee_per_gas' : '0x' ,
242295 'nonce' : 1 ,
@@ -265,7 +318,8 @@ describe('Eth calls using MirrorNode', async function () {
265318 'timestamp' : contractTimestamp2 ,
266319 'block_hash' : blockHash2 ,
267320 'block_number' : blockNumber2 ,
268- 'hash' : contractHash2
321+ 'hash' : contractHash2 ,
322+ 'logs' : defaultLogs2
269323 }
270324 } ;
271325
@@ -276,6 +330,7 @@ describe('Eth calls using MirrorNode', async function () {
276330 'block_number' : blockNumber3 ,
277331 'hash' : contractHash3 ,
278332 'contract_id' : contractId2 ,
333+ 'logs' : defaultLogs3
279334 }
280335 } ;
281336
@@ -290,63 +345,6 @@ describe('Eth calls using MirrorNode', async function () {
290345 const results = defaultContractResults . results ;
291346 const totalGasUsed = EthImpl . numberTo0x ( results [ 0 ] . gas_used + results [ 1 ] . gas_used ) ;
292347
293- const logBloom1 = '0x1111' ;
294- const logBloom2 = '0x2222' ;
295- const logBloom3 = '0x3333' ;
296- const logBloom4 = '0x4444' ;
297-
298- const defaultLogTopics = [
299- "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" ,
300- "0x0000000000000000000000000000000000000000000000000000000000000000" ,
301- "0x000000000000000000000000000000000000000000000000000000000208fa13" ,
302- "0x0000000000000000000000000000000000000000000000000000000000000005"
303- ] ;
304-
305- const defaultLogs = {
306- "logs" : [
307- {
308- "address" : "0x0000000000000000000000000000000002131951" ,
309- "bloom" : logBloom1 ,
310- "contract_id" : contractId1 ,
311- "data" : "0x" ,
312- "index" : 0 ,
313- "topics" : defaultLogTopics ,
314- "root_contract_id" : "0.0.34806097" ,
315- "timestamp" : contractTimestamp1
316- } ,
317- {
318- "address" : "0x0000000000000000000000000000000002131951" ,
319- "bloom" : logBloom2 ,
320- "contract_id" : contractId1 ,
321- "data" : "0x" ,
322- "index" : 1 ,
323- "topics" : defaultLogTopics ,
324- "root_contract_id" : "0.0.34806097" ,
325- "timestamp" : contractTimestamp1
326- } ,
327- {
328- "address" : "0x0000000000000000000000000000000002131951" ,
329- "bloom" : logBloom3 ,
330- "contract_id" : contractId1 ,
331- "data" : "0x" ,
332- "index" : 0 ,
333- "topics" : [ ] ,
334- "root_contract_id" : "0.0.34806097" ,
335- "timestamp" : contractTimestamp2
336- } ,
337- {
338- "address" : "0x0000000000000000000000000000000002131951" ,
339- "bloom" : logBloom4 ,
340- "contract_id" : contractId2 ,
341- "data" : "0x" ,
342- "index" : 0 ,
343- "topics" : [ ] ,
344- "root_contract_id" : "0.0.34806097" ,
345- "timestamp" : contractTimestamp3
346- }
347- ]
348- } ;
349-
350348 const defaultNetworkFees = {
351349 'fees' : [
352350 {
@@ -895,13 +893,13 @@ describe('Eth calls using MirrorNode', async function () {
895893
896894 describe ( 'eth_getLogs' , async function ( ) {
897895
898- const expectLogData = ( res , log , tx ) => {
896+ const expectLogData = ( res , log , tx , blockLogIndexOffset ) => {
899897 expect ( res . address ) . to . eq ( log . address ) ;
900898 expect ( res . blockHash ) . to . eq ( EthImpl . toHash32 ( tx . block_hash ) ) ;
901899 expect ( res . blockHash . length ) . to . eq ( 66 ) ;
902900 expect ( res . blockNumber ) . to . eq ( tx . block_number ) ;
903901 expect ( res . data ) . to . eq ( log . data ) ;
904- expect ( res . logIndex ) . to . eq ( log . index ) ;
902+ expect ( res . logIndex ) . to . eq ( blockLogIndexOffset + log . index ) ;
905903 expect ( res . removed ) . to . eq ( false ) ;
906904 expect ( res . topics ) . to . exist ;
907905 expect ( res . topics ) . to . deep . eq ( log . topics ) ;
@@ -911,19 +909,20 @@ describe('Eth calls using MirrorNode', async function () {
911909 } ;
912910
913911 const expectLogData1 = ( res ) => {
914- expectLogData ( res , defaultLogs . logs [ 0 ] , defaultDetailedContractResults ) ;
912+ expectLogData ( res , defaultLogs . logs [ 0 ] , defaultDetailedContractResults , 0 ) ;
915913 } ;
916914
917915 const expectLogData2 = ( res ) => {
918- expectLogData ( res , defaultLogs . logs [ 1 ] , defaultDetailedContractResults ) ;
916+ expectLogData ( res , defaultLogs . logs [ 1 ] , defaultDetailedContractResults , 0 ) ;
919917 } ;
920918
921919 const expectLogData3 = ( res ) => {
922- expectLogData ( res , defaultLogs . logs [ 2 ] , defaultDetailedContractResults2 ) ;
920+ expectLogData ( res , defaultLogs . logs [ 2 ] , defaultDetailedContractResults2 , defaultDetailedContractResults . logs . length ) ;
923921 } ;
924922
923+ const transaction3LogOffset = defaultDetailedContractResults . logs . length + defaultDetailedContractResults2 . logs . length ;
925924 const expectLogData4 = ( res ) => {
926- expectLogData ( res , defaultLogs . logs [ 3 ] , defaultDetailedContractResults3 ) ;
925+ expectLogData ( res , defaultLogs . logs [ 3 ] , defaultDetailedContractResults3 , transaction3LogOffset ) ;
927926 } ;
928927
929928 it ( 'contract results details not found' , async function ( ) {
0 commit comments