-
Notifications
You must be signed in to change notification settings - Fork 339
/
EventRecord.spec.ts
53 lines (42 loc) · 1.83 KB
/
EventRecord.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2017-2019 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import Metadata from '@polkadot/metadata/Metadata';
import rpcMetadataV0 from '@polkadot/metadata/Metadata/v0/static';
import rpcMetadata from '@polkadot/metadata/Metadata/static';
import { createType, TypeRegistry } from '../../codec/create';
import json1 from '../../json/EventRecord.001.json';
import json3 from '../../json/EventRecord.003.json';
describe('EventRecord', (): void => {
const registry = new TypeRegistry();
describe('EventRecordTo76', (): void => {
beforeEach((): void => {
// eslint-disable-next-line no-new
new Metadata(registry, rpcMetadataV0);
});
it('decodes correctly', (): void => {
const records = createType(registry, 'Vec<EventRecord>', json1.params.result.changes[0][1]) as any;
const er = records[0];
expect(er.phase.type).toEqual('ApplyExtrinsic');
});
});
describe('EventRecord (current)', (): void => {
beforeEach((): void => {
// eslint-disable-next-line no-new
new Metadata(registry, rpcMetadata);
});
it('decodes older eventrecord correctly', (): void => {
const records = createType(registry, 'Vec<EventRecord>', json1.params.result.changes[0][1], true) as any;
const er = records[0];
expect(er.phase.type).toEqual('ApplyExtrinsic');
});
it('decodes eventrecord with topics correctly', (): void => {
const hex = json3.params.result.changes[0][1];
const records = createType(registry, 'Vec<EventRecord>', hex, true) as any;
const er = records[0];
expect(er.phase.type).toEqual('ApplyExtrinsic');
// additional payment info
expect(records.toHex()).toEqual(`${hex}000000000000`);
});
});
});