Skip to content

Commit

Permalink
complete tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mfornos committed Jul 4, 2023
1 parent 9d26497 commit 7235506
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/apis/substrate-apis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@ describe('substrate APIs', () => {
it('should throw error on missing apis', () => {
expect(apis.promise.polkadot.isConnected).toBeFalsy();
expect(apis.rx.polkadot.pipe).toBeDefined();
expect(apis.query.polkadot.pipe).toBeDefined();
expect(apis.queryMulti.polkadot.pipe).toBeDefined();

expect(() => {
apis.promise.none.isConnected;
}).toThrowError();
expect(() => {
apis.rx.none.pipe();
}).toThrowError();
expect(() => {
apis.query.none.pipe();
}).toThrowError();
expect(() => {
apis.queryMulti.none.pipe();
}).toThrowError();
});

it('should be instantiated', () => {
Expand All @@ -54,6 +62,10 @@ describe('substrate APIs', () => {
expect(apis.rx.polkadot).toBeDefined();
expect(apis.promise.rococo).toBeDefined();
expect(apis.rx.rococo).toBeDefined();
expect(apis.query).toBeDefined();
expect(apis.query.rococo).toBeDefined();
expect(apis.queryMulti).toBeDefined();
expect(apis.queryMulti.rococo).toBeDefined();
});

it('should trigger the disconnection of all the providers', async () => {
Expand Down
25 changes: 25 additions & 0 deletions packages/core/src/converters/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ describe('substrate converters', () => {
.toBe('0x382951a7547ec688051e1d95c0589eb8bd247bd4451cf66af35cdfee0f674692');
});

it('should convert an extrinsic', () => {
const xt = testBlocks[0].block.extrinsics[0];
const c = base.toNamedPrimitive(xt) as any;

expect(c).toBeDefined();
expect(c.hash)
.toBe('0x9e754973630b425e486445ed1600409c97d63a7c2a0679d949d008d784acc917');
});

it('should convert all the test blocks', () => {
for (let i = 0; i < testBlocks.length; i++) {
const b = base.toNamedPrimitive(testBlocks[i]) as any;
Expand Down Expand Up @@ -93,4 +102,20 @@ describe('substrate converters', () => {

expect(typeof c.extrinsics[2].extrinsic.call.args.value).toBe('string');
});

it('should convert codec objects', () => {
const b = testBlocks[0];
const v = b.block.header;
const c = base.toNamedPrimitive(v) as any;

expect(c.number).toBe(15950017);
});

it('should convert codec values', () => {
const b = testBlocks[0];
const v = b.block.header.number;
const c = base.toNamedPrimitive(v) as any;

expect(c.value).toBe(15950017);
});
});
1 change: 1 addition & 0 deletions packages/core/src/operators/debug.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* istanbul ignore file */
import { Logger } from '@polkadot/util/types';
import type { AnyJson } from '@polkadot/types-codec/types';

Expand Down

0 comments on commit 7235506

Please sign in to comment.