Newer
Older
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
import { balanceTransfer } from '../balanceTransfer';
import { createSignedTx } from '../createSignedTx';
import { createSigningPayload } from '../createSigningPayload';
import { metadataRpc, signWithAlice, TEST_TX_INFO } from '../util/testUtil';
import { decode } from './decode';
describe('decode', () => {
it('should decode signedTx', async done => {
const unsigned = balanceTransfer(TEST_TX_INFO);
const signingPayload = createSigningPayload(unsigned);
const signature = await signWithAlice(signingPayload);
const signedTx = createSignedTx(unsigned, signature);
const txInfo = decode(signedTx, metadataRpc);
([
'amount',
'keepAlive',
'metadataRpc',
'nonce',
'tip',
'to'
] as const).forEach(key => expect(txInfo[key]).toBe(TEST_TX_INFO[key]));
expect(txInfo.validityPeriod).toBeGreaterThanOrEqual(
TEST_TX_INFO.validityPeriod
);
done();
});
it('should decode signingPayload', () => {
const signingPayload = createSigningPayload(balanceTransfer(TEST_TX_INFO));
const txInfo = decode(signingPayload, metadataRpc);
([
'amount',
'keepAlive',
'metadataRpc',
'nonce',
'tip',
'to'
] as const).forEach(key => expect(txInfo[key]).toBe(TEST_TX_INFO[key]));
expect(txInfo.validityPeriod).toBeGreaterThanOrEqual(
TEST_TX_INFO.validityPeriod
);
});
});