| 
1 | 1 | const chai = require('chai')  | 
2 |  | -const assert = chai.assert;  | 
3 | 2 | const chaiAsPromised = require('chai-as-promised');  | 
4 |  | -chai.use(chaiAsPromised);  | 
5 |  | -const {expect} = chai;  | 
6 |  | - | 
7 | 3 | const sinon = require('sinon');  | 
8 | 4 | const rewire = require('rewire');  | 
9 | 5 | 
 
  | 
 | 6 | +const assert = chai.assert;  | 
 | 7 | +chai.use(chaiAsPromised);  | 
 | 8 | +const {expect} = chai;  | 
 | 9 | + | 
10 | 10 | const bridgeTransactionParserModule = rewire('../index');  | 
11 | 11 | const BridgeTransactionParser = bridgeTransactionParserModule.__get__('BridgeTransactionParser');  | 
12 | 12 | 
 
  | 
@@ -217,21 +217,50 @@ const blocksStub = [  | 
217 | 217 |             '0x6547e88a30d1b43c6fbea07fa7443dfeb697d076495c3e4fc56ebf40228e0431', // Not bridge transaction  | 
218 | 218 |             '0x7f6c029fba670f1ee14729e5531c672e813ac1ef4c86dec313b090119c14fa78', // Not bridge transaction  | 
219 | 219 |             '0x73a4d1592c5e922c2c6820985982d2715538717e4b4b52502685bc4c924300b7' // Bridge transaction  | 
220 |  | -        ]  | 
 | 220 | +        ],  | 
 | 221 | +        timestamp: 1683234772  | 
221 | 222 |     },  | 
222 | 223 |     {  | 
223 | 224 |         number: 1002,  | 
224 | 225 |         hash: '0xcdc8e7d4d5417ae5a36c6c246fa34df2ec0ebc9056055eeea401dc95e85e98f1',  | 
225 | 226 |         transactions: [  | 
226 | 227 |             '0x719715d6dc0617b6495d74aa4aa21b0755057ef6ad7cdcb71bdffcc2b3af4b24' // Not bridge transaction  | 
227 |  | -        ]  | 
 | 228 | +        ],  | 
 | 229 | +        timestamp: 1688764372  | 
228 | 230 |     },  | 
229 | 231 |     {  | 
230 | 232 |         number: 1003,  | 
231 | 233 |         hash: '0x5f4da1a8bc0f04fd1bca304cbfca19bbf618307a8855bfd71841428a83474f20',  | 
232 | 234 |         transactions: [  | 
233 | 235 |             '0x7a3c39f59e1f2c624602c9b54c28155a251963ec878049c0f78a7d281b2e3b87' // Bridge transaction  | 
234 |  | -        ]  | 
 | 236 | +        ],  | 
 | 237 | +        timestamp: 1694023972  | 
 | 238 | +    },  | 
 | 239 | +    {  | 
 | 240 | +        number: 1004,  | 
 | 241 | +        hash: '0x3c57396af7db18317efa29a3e4de1c4b66fe3f0e49b6236f62d30927d107d030',  | 
 | 242 | +        transactions: [  | 
 | 243 | +            '0x112439355294e02096078c3b77cb12546fe79d284f46d478b3584873c2bacb8b' // Bridge transaction  | 
 | 244 | +        ],  | 
 | 245 | +        timestamp: 1697289052  | 
 | 246 | +    },  | 
 | 247 | +    {  | 
 | 248 | +        number: 1005,  | 
 | 249 | +        hash: '0xa2ee5fddb10d16e9b1bf0e9e8afdf5cb4efd9e84d4d308ef4949da6068cd9d16',  | 
 | 250 | +        transactions: [  | 
 | 251 | +            '0x73a4d1592c5e922c2c6820985982d2715538717e4b4b52502685bc4c924300b7', // Bridge transaction  | 
 | 252 | +            '0x6de85c65973ade9993a6f5c02603e979ac3c09dc18a3206421c2931d559b64ed' // Not bridge transaction  | 
 | 253 | +        ],  | 
 | 254 | +        timestamp: 1710421852  | 
 | 255 | +    },  | 
 | 256 | +    {  | 
 | 257 | +        number: 1006,  | 
 | 258 | +        hash: '0x3411a34eaf3c239595642db1225c34c137833672460d45afc4140e4d4aeaa390',  | 
 | 259 | +        transactions: [  | 
 | 260 | +            '0x7a3c39f59e1f2c624602c9b54c28155a251963ec878049c0f78a7d281b2e3b87', // Bridge transaction  | 
 | 261 | +            '0xfd9012ec6b585186fabb8b48e75dca559be5e197ea776139cbf35816914a2dfa' // Not bridge transaction  | 
 | 262 | +        ],  | 
 | 263 | +        timestamp: 1754170133  | 
235 | 264 |     }  | 
236 | 265 | ]  | 
237 | 266 | 
 
  | 
@@ -361,13 +390,16 @@ describe('Get Bridge transaction by tx hash', () => {  | 
361 | 390 | 
 
  | 
362 | 391 |     it('Should verify and return Bridge transaction from tx hash', async () => {  | 
363 | 392 |         const txReceipt = txReceiptsStub[4];  | 
 | 393 | +        const block = web3ClientStub.eth.getBlock(txReceipt.blockNumber);  | 
364 | 394 |         const result = await bridgeTransactionParser.getBridgeTransactionByTxHash(  | 
365 | 395 |             txReceipt.transactionHash  | 
366 | 396 |         );  | 
367 | 397 | 
 
  | 
368 | 398 |         assert.equal(result.txHash, txReceipt.transactionHash);  | 
369 | 399 |         assert.equal(result.sender, txReceipt.from);  | 
370 | 400 |         assert.equal(result.blockNumber, txReceipt.blockNumber);  | 
 | 401 | +        assert.equal(result.blockNumber, block.number);  | 
 | 402 | +        assert.equal(result.blockTimestamp, block.timestamp);  | 
371 | 403 | 
 
  | 
372 | 404 |         assert.equal(result.method.name, "updateCollections");  | 
373 | 405 |         assert.equal(result.method.signature, "0x0c5a9990");  | 
@@ -468,7 +500,7 @@ describe('Get Bridge transactions from multiple blocks', () => {  | 
468 | 500 |             .to.be.rejectedWith('blocksToSearch must be greater than 0 or less than 100');  | 
469 | 501 |     });  | 
470 | 502 | 
 
  | 
471 |  | -    it('Should Verify And Return Bridge Transactions From Blocks', async () => {  | 
 | 503 | +    it('Should verify and return Bridge transactions from blocks', async () => {  | 
472 | 504 |         const startingBlockNumber = 1001;  | 
473 | 505 |         const blocksToSearch = 3;  | 
474 | 506 |         const result = await bridgeTransactionParser.getBridgeTransactionsSinceThisBlock(startingBlockNumber, blocksToSearch);  | 
 | 
0 commit comments