Skip to content

Commit

Permalink
Fixing failing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauan committed Sep 19, 2024
1 parent 7bf82a4 commit a1aeeb6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sdk/src/network-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ class AleoNetworkClient {
* @example
* const latestHeight = networkClient.getLatestHeight();
*/
async getLatestHeight(): Promise<number> {
async getLatestHeight(): Promise<bigint> {
try {
return await this.fetchData<number>("/latest/height");
return await this.fetchData<bigint>("/latest/height");
} catch (error) {
throw new Error("Error fetching latest height.");
}
Expand Down
8 changes: 2 additions & 6 deletions sdk/src/record-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/network-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down

0 comments on commit a1aeeb6

Please sign in to comment.