Skip to content

Commit

Permalink
test: fix data
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosvdr committed Mar 21, 2024
1 parent 575820f commit 9c02559
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
21 changes: 17 additions & 4 deletions packages/indexer-common/src/allocations/__tests__/tap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
GraphNode,
Network,
QueryFeeModels,
ReceiptAggregateVoucher,
} from '@graphprotocol/indexer-common'
import {
connectDatabase,
Expand All @@ -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,
Expand Down Expand Up @@ -74,6 +76,9 @@ const rav = {
'hex',
),
senderAddress: toAddress('ffcf8fdee72ac11b5c542428b35eef5769c409f0'),
redeemedAt: null,
createdAt: new Date(),
updatedAt: new Date(),
}

const setupEach = async () => {
Expand All @@ -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 = {
Expand All @@ -128,7 +141,7 @@ describe('TAP', () => {
)

expect(signerAddress).toEqual('0x886574712d0ca20C36FD090A594Df7eCa17cd38e')
}),
}, timeout),
test('test submitRAVs', async () => {})

test('test RAV Processing eventual', async () => {})
Expand Down
18 changes: 15 additions & 3 deletions packages/indexer-common/src/query-fees/__test__/rav.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})])
})
})

0 comments on commit 9c02559

Please sign in to comment.