From 9c02559d75d21cf5122425d2d78774bb18f6824b Mon Sep 17 00:00:00 2001 From: Carlos V Date: Thu, 21 Mar 2024 05:38:01 +0000 Subject: [PATCH] test: fix data --- .../src/allocations/__tests__/tap.test.ts | 21 +++++++++++++++---- .../src/query-fees/__test__/rav.test.ts | 18 +++++++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/packages/indexer-common/src/allocations/__tests__/tap.test.ts b/packages/indexer-common/src/allocations/__tests__/tap.test.ts index 8d9557c1d..759a2618e 100644 --- a/packages/indexer-common/src/allocations/__tests__/tap.test.ts +++ b/packages/indexer-common/src/allocations/__tests__/tap.test.ts @@ -4,6 +4,7 @@ import { GraphNode, Network, QueryFeeModels, + ReceiptAggregateVoucher, } from '@graphprotocol/indexer-common' import { connectDatabase, @@ -26,6 +27,7 @@ let receiptCollector: AllocationReceiptCollector let metrics: Metrics let queryFeeModels: QueryFeeModels let sequelize: Sequelize +const timeout = 30000 const startRAVProcessing = jest.spyOn( AllocationReceiptCollector.prototype, @@ -74,6 +76,9 @@ const rav = { 'hex', ), senderAddress: toAddress('ffcf8fdee72ac11b5c542428b35eef5769c409f0'), + redeemedAt: null, + createdAt: new Date(), + updatedAt: new Date(), } const setupEach = async () => { @@ -98,11 +103,19 @@ describe('TAP', () => { test('test if startRAVProcessing is called', async () => { expect(startRAVProcessing).toHaveBeenCalled() - }) + }, timeout) test('test getPendingRAVsEventual', async () => { const ravs = await receiptCollector['pendingRAVs']() - expect(ravs).toEqual([expect.objectContaining(rav)]) - }) + expect(ravs).toEqual([expect.objectContaining({ + allocationId: rav.allocationId, + final: rav.final, + last: rav.last, + senderAddress: rav.senderAddress, + signature: rav.signature, + timestampNs: BigInt(rav.timestampNs).toString(), + valueAggregate: BigInt(rav.valueAggregate).toString(), + })]) + }, timeout) test('check signature rav', async () => { const domain = { @@ -128,7 +141,7 @@ describe('TAP', () => { ) expect(signerAddress).toEqual('0x886574712d0ca20C36FD090A594Df7eCa17cd38e') - }), + }, timeout), test('test submitRAVs', async () => {}) test('test RAV Processing eventual', async () => {}) diff --git a/packages/indexer-common/src/query-fees/__test__/rav.test.ts b/packages/indexer-common/src/query-fees/__test__/rav.test.ts index 81292e41f..7dc5fbc5c 100644 --- a/packages/indexer-common/src/query-fees/__test__/rav.test.ts +++ b/packages/indexer-common/src/query-fees/__test__/rav.test.ts @@ -15,17 +15,29 @@ describe('RavData', () => { final: false, last: true, senderAddress: toAddress('0xabababababababababababababababababababab'), - timestampNs: 18446744073709551605n, - valueAggregate: 340282366920938463463374607431768211455n, + timestampNs: 1709067401177959664n, + valueAggregate: 20000000000000n, signature: Buffer.from( '0x56f8e2b7fecee908ff0d28ed172a61bee8ffe87b498c23da7eaca74cd7c5b5ce4ead667e3eb4f1d8c4a20e6f0e5dbe73f9f63e9d0d23e606b3239332c5f213371b', 'hex', ), + redeemedAt: null, + createdAt: new Date(), + updatedAt: new Date(), } + await queryFeeModels.receiptAggregateVouchers.create(value) const result = await queryFeeModels.receiptAggregateVouchers.findAll() // expect([value]).toEqual(result) - expect(result).toEqual([expect.objectContaining(value)]) + expect(result).toEqual([expect.objectContaining({ + allocationId: value.allocationId, + final: value.final, + last: value.last, + senderAddress: value.senderAddress, + signature: value.signature, + timestampNs: BigInt(value.timestampNs).toString(), + valueAggregate: BigInt(value.valueAggregate).toString(), + })]) }) })