From 64282609604d8ae6d52aa46ee944e991dee84278 Mon Sep 17 00:00:00 2001 From: Torres-ssf Date: Mon, 20 Jan 2025 09:10:44 -0300 Subject: [PATCH] uncomment tests related to balance pagination --- .../account/src/providers/provider.test.ts | 98 ++++++++++--------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/packages/account/src/providers/provider.test.ts b/packages/account/src/providers/provider.test.ts index dc81fd24cd4..ba023f7d69a 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -2187,48 +2187,52 @@ describe('Provider', () => { expect(pageInfo.endCursor).toBeDefined(); }); - // it('can get balances', async () => { - // using launched = await setupTestProviderAndWallets({ - // walletsConfig: { - // assets: 110, - // }, - // }); - // const { - // provider, - // wallets: [wallet], - // } = launched; - - // let { balances, pageInfo } = await provider.getBalances(wallet.address, { first: 10 }); - - // expect(balances.length).toBe(10); - // expect(pageInfo.hasNextPage).toBeTruthy(); - // expect(pageInfo.hasPreviousPage).toBeFalsy(); - // expect(pageInfo.startCursor).toBeDefined(); - // expect(pageInfo.endCursor).toBeDefined(); - - // ({ balances, pageInfo } = await provider.getBalances(wallet.address, { - // after: pageInfo.endCursor, - // })); - - // expect(balances.length).toBe(100); - // expect(pageInfo.hasNextPage).toBeFalsy(); - // expect(pageInfo.hasPreviousPage).toBeTruthy(); - // expect(pageInfo.startCursor).toBeDefined(); - // expect(pageInfo.endCursor).toBeDefined(); - - // ({ balances, pageInfo } = await provider.getBalances(wallet.address, { - // before: pageInfo.startCursor, - // last: 10, - // })); - - // expect(balances.length).toBe(10); - // expect(pageInfo.hasNextPage).toBeFalsy(); - // expect(pageInfo.hasPreviousPage).toBeTruthy(); - // expect(pageInfo.startCursor).toBeDefined(); - // expect(pageInfo.endCursor).toBeDefined(); - // }); - - it.todo('can get balances amount greater than u64', () => {}); + it('can get balances', async () => { + using launched = await setupTestProviderAndWallets({ + walletsConfig: { + assets: 110, + }, + }); + const { + provider, + wallets: [wallet], + } = launched; + + let { balances, pageInfo } = await provider.getBalances(wallet.address, { first: 10 }); + + pageInfo = pageInfo as GqlPageInfo; + + expect(balances.length).toBe(10); + expect(pageInfo.hasNextPage).toBeTruthy(); + expect(pageInfo.hasPreviousPage).toBeFalsy(); + expect(pageInfo.startCursor).toBeDefined(); + expect(pageInfo.endCursor).toBeDefined(); + + ({ balances, pageInfo } = await provider.getBalances(wallet.address, { + after: pageInfo.endCursor, + })); + + pageInfo = pageInfo as GqlPageInfo; + + expect(balances.length).toBe(100); + expect(pageInfo.hasNextPage).toBeFalsy(); + expect(pageInfo.hasPreviousPage).toBeTruthy(); + expect(pageInfo.startCursor).toBeDefined(); + expect(pageInfo.endCursor).toBeDefined(); + + ({ balances, pageInfo } = await provider.getBalances(wallet.address, { + before: pageInfo.startCursor, + last: 10, + })); + + pageInfo = pageInfo as GqlPageInfo; + + expect(balances.length).toBe(10); + expect(pageInfo.hasNextPage).toBeFalsy(); + expect(pageInfo.hasPreviousPage).toBeTruthy(); + expect(pageInfo.startCursor).toBeDefined(); + expect(pageInfo.endCursor).toBeDefined(); + }); describe('pagination arguments', async () => { using launched = await setupTestProviderAndWallets({ @@ -2259,11 +2263,11 @@ describe('Provider', () => { invocation: () => provider.getBlocks(args), limit: BLOCKS_PAGE_SIZE_LIMIT, }, - // { - // name: 'getBalances', - // invocation: () => provider.getBalances(address, args), - // limit: BALANCES_PAGE_SIZE_LIMIT, - // }, + { + name: 'getBalances', + invocation: () => provider.getBalances(address, args), + limit: BALANCES_PAGE_SIZE_LIMIT, + }, ]; }