From adf39a40895712a37f6811a548ac8e5c03c9139c Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Fri, 6 Sep 2024 09:35:58 +0530 Subject: [PATCH] Update bonds test --- src/bond.test.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bond.test.ts b/src/bond.test.ts index b64e35e..2eb2898 100644 --- a/src/bond.test.ts +++ b/src/bond.test.ts @@ -13,6 +13,7 @@ jest.setTimeout(90 * 1000); const bondTests = () => { let registry: Registry; + let bond: any; const publishNewWatcherVersion = async (bondId: string) => { let watcher = await ensureUpdatedConfig(WATCHER_YML_PATH); @@ -28,6 +29,8 @@ const bondTests = () => { let bondId = await registry.getNextBondId(privateKey); expect(bondId).toBeDefined(); await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, privateKey, fee); + + [bond] = await registry.getBondsByIds([bondId]); }); describe('With bond created', () => { @@ -68,15 +71,16 @@ const bondTests = () => { const { id: bondId2 } = await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, otherAccount.getPrivateKey(), fee); - const [owner1Bonds] = await registry.queryBondsByOwner(bond1.owner); - expect(owner1Bonds.bonds).toHaveLength(2); - const owner1Bond = owner1Bonds.bonds.filter((bond: any) => bond.id === bond1.id); - expect(owner1Bond).toBeDefined(); + const [owner1Bonds] = await registry.queryBondsByOwner(bond.owner); + const owner1Bond1 = owner1Bonds.bonds.filter((b: any) => b.id === bond.id); + const owner1Bond2 = owner1Bonds.bonds.filter((b: any) => b.id === bond1.id); + expect(owner1Bond1).toBeDefined(); + expect(owner1Bond2).toBeDefined(); const [bond2] = await registry.getBondsByIds([bondId2]); const [owner2Bonds] = await registry.queryBondsByOwner(bond2.owner); expect(owner2Bonds.bonds).toHaveLength(1); - const owner2Bond = owner2Bonds.bonds.filter((bond: any) => bond.id === bond2.id); + const owner2Bond = owner2Bonds.bonds.filter((b: any) => b.id === bondId2); expect(owner2Bond).toBeDefined(); });