Skip to content

Commit bd6ef4e

Browse files
authored
feat(api) add missing pallet tests (#1666)
1 parent 4427b09 commit bd6ef4e

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

api/src/Builtin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { HexString } from 'types';
22
import { GearApi } from './GearApi';
3-
import { u64 } from '@polkadot/types-codec';
43
import { BuiltinQueryIdError } from './errors';
54

65
export class GearBuiltin {
76
constructor(private _api: GearApi) {}
87

9-
async queryId(builtinId: u64): Promise<HexString> {
8+
async queryId(builtinId: number | bigint): Promise<HexString> {
109
try {
11-
const result = await this._api.rpc.gearBuiltin.queryId(builtinId);
10+
const valueId = this._api.createType('u64', BigInt(builtinId));
11+
const result = await this._api.rpc.gearBuiltin.queryId(valueId);
1212
return result.toHex();
1313
} catch (err) {
1414
throw new BuiltinQueryIdError(err.message);

api/test/Builtin.test.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { GearApi } from '../src';
2+
import { sleep } from './utilsFunctions';
3+
import { WS_ADDRESS } from './config';
4+
import { BN } from '@polkadot/util';
5+
6+
const api = new GearApi({ providerAddress: WS_ADDRESS });
7+
8+
beforeAll(async () => {
9+
await api.isReadyOrError;
10+
});
11+
12+
afterAll(async () => {
13+
await api.disconnect();
14+
await sleep(1000);
15+
});
16+
17+
describe('Query id', () => {
18+
test('Random query id', async () => {
19+
const builtinId = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
20+
21+
const id = await api.builtin.queryId(builtinId);
22+
expect(id.length).toBe(66);
23+
});
24+
});

0 commit comments

Comments
 (0)