From a1aeeb63dc828c33449b703d93d86ea7763abc8b Mon Sep 17 00:00:00 2001 From: Pauan Date: Sat, 7 Sep 2024 16:51:09 -0700 Subject: [PATCH] Fixing failing unit test --- sdk/src/network-client.ts | 4 ++-- sdk/src/record-provider.ts | 8 ++------ sdk/tests/network-client.test.ts | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/sdk/src/network-client.ts b/sdk/src/network-client.ts index 9af79afb1..77b8992f0 100644 --- a/sdk/src/network-client.ts +++ b/sdk/src/network-client.ts @@ -390,9 +390,9 @@ class AleoNetworkClient { * @example * const latestHeight = networkClient.getLatestHeight(); */ - async getLatestHeight(): Promise { + async getLatestHeight(): Promise { try { - return await this.fetchData("/latest/height"); + return await this.fetchData("/latest/height"); } catch (error) { throw new Error("Error fetching latest height."); } diff --git a/sdk/src/record-provider.ts b/sdk/src/record-provider.ts index f3d025ec8..c56664a90 100644 --- a/sdk/src/record-provider.ts +++ b/sdk/src/record-provider.ts @@ -202,12 +202,8 @@ class NetworkRecordProvider implements RecordProvider { // If the end height is not specified, use the current block height if (endHeight == 0) { - try { - const end = await this.networkClient.getLatestHeight(); - endHeight = end; - } catch (e) { - logAndThrow("Unable to get current block height from the network") - } + const end = await this.networkClient.getLatestHeight(); + endHeight = Number(end); } // If the start height is greater than the end height, throw an error diff --git a/sdk/tests/network-client.test.ts b/sdk/tests/network-client.test.ts index 48a7814a7..287bd607a 100644 --- a/sdk/tests/network-client.test.ts +++ b/sdk/tests/network-client.test.ts @@ -100,7 +100,7 @@ describe('NodeConnection', () => { describe('getLatestHeight', () => { it('should return a number', async () => { const latestHeight = await connection.getLatestHeight(); - expect(typeof latestHeight).toBe('number'); + expect(typeof latestHeight).toBe('bigint'); }, 60000); });