|
| 1 | +// Copyright 2017-2022 @polkadot/types authors & contributors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +import rpcMetadata from '@polkadot/types-support/metadata/static-substrate'; |
| 5 | + |
| 6 | +import { TypeRegistry } from '../../create'; |
| 7 | +import { decorateExtrinsics, Metadata } from '../../metadata'; |
| 8 | +import { GenericExtrinsicPayloadV4 as ExtrinsicPayload } from '.'; |
| 9 | + |
| 10 | +const registry = new TypeRegistry(); |
| 11 | +const metadata = new Metadata(registry, rpcMetadata); |
| 12 | + |
| 13 | +registry.setMetadata(metadata); |
| 14 | + |
| 15 | +const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version); |
| 16 | + |
| 17 | +describe('ExtrinsicPayload', (): void => { |
| 18 | + it('has a sane inspect', (): void => { |
| 19 | + // we don't expect this to fail, however it is actually a good |
| 20 | + // reference for the ordering in base Substrate |
| 21 | + expect(new ExtrinsicPayload(registry, { method: tx.timestamp.set(0).toHex() } as never).inspect()).toEqual({ |
| 22 | + inner: [ |
| 23 | + { name: 'method', outer: [new Uint8Array([3, 0, 0])] }, |
| 24 | + { name: 'era', outer: [new Uint8Array([0]), new Uint8Array([0])] }, |
| 25 | + { name: 'nonce', outer: [new Uint8Array([0])] }, |
| 26 | + { name: 'tip', outer: [new Uint8Array([0])] }, |
| 27 | + { name: 'assetId', outer: [new Uint8Array([0])] }, |
| 28 | + { name: 'specVersion', outer: [new Uint8Array([0, 0, 0, 0])] }, |
| 29 | + { name: 'transactionVersion', outer: [new Uint8Array([0, 0, 0, 0])] }, |
| 30 | + { name: 'genesisHash', outer: [new Uint8Array(32)] }, |
| 31 | + { name: 'blockHash', outer: [new Uint8Array(32)] } |
| 32 | + ] |
| 33 | + }); |
| 34 | + }); |
| 35 | +}); |
0 commit comments