From c8d4783577cbcaae39c11ab30fd04ad5ba9438f7 Mon Sep 17 00:00:00 2001 From: neeraj Date: Tue, 12 Mar 2024 12:00:39 +0530 Subject: [PATCH] Expect null if bond or authority is not found --- src/bond.test.ts | 4 +--- src/naming.test.ts | 5 +---- src/registry-client.ts | 2 +- src/sdk.test.ts | 3 +-- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/bond.test.ts b/src/bond.test.ts index 681c787..92124dc 100644 --- a/src/bond.test.ts +++ b/src/bond.test.ts @@ -88,9 +88,7 @@ const bondTests = () => { test('Cancel bond.', async () => { await registry.cancelBond({ id: bond1.id }, privateKey, fee); const [bond] = await registry.getBondsByIds([bond1.id]); - expect(bond.id).toBe(''); - expect(bond.owner).toBe(''); - expect(bond.balance).toHaveLength(0); + expect(bond).toBe(null); }); }); diff --git a/src/naming.test.ts b/src/naming.test.ts index 12320ef..71ce007 100644 --- a/src/naming.test.ts +++ b/src/naming.test.ts @@ -69,10 +69,7 @@ const namingTests = () => { test('Lookup non existing authority', async () => { const [record] = await registry.lookupAuthorities(['does-not-exist']); - - expect(record.ownerAddress).toBe(''); - expect(record.ownerPublicKey).toBe(''); - expect(Number(record.height)).toBe(0); + expect(record).toBe(null); }); test('Reserve already reserved authority', async () => { diff --git a/src/registry-client.ts b/src/registry-client.ts index 6b6852c..9372926 100644 --- a/src/registry-client.ts +++ b/src/registry-client.ts @@ -105,7 +105,7 @@ export class RegistryClient { */ static async getResult (query: any, key: string, modifier?: (rows: any[]) => {}) { const result = await query; - if (result && result[key] && result[key].length && result[key][0] !== null) { + if (result && result[key]) { if (modifier) { return modifier(result[key]); } diff --git a/src/sdk.test.ts b/src/sdk.test.ts index 885cb63..a69edaf 100644 --- a/src/sdk.test.ts +++ b/src/sdk.test.ts @@ -36,8 +36,7 @@ describe('Querying', () => { expect(registry.chainID).toBe(chainId); }); - // TODO: Check get status error - xtest('Get status.', async () => { + test('Get status.', async () => { const status = await registry.getStatus(); expect(status).toBeDefined(); expect(status.version).toBeDefined();