-
Notifications
You must be signed in to change notification settings - Fork 285
/
Copy pathpath-test.js
67 lines (55 loc) · 1.39 KB
/
path-test.js
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
const assert = require('bsert');
const MTX = require('../lib/primitives/mtx');
const Path = require('../lib/wallet/path');
const mtx1json = require('./data/mtx1.json');
const mtx1 = MTX.fromJSON(mtx1json);
describe('MTX', function() {
it('should serialize path', () => {
const input = mtx1.inputs[0];
const view = mtx1.view;
const path = view.getPathFor(input);
{
const got = path.getJSON();
const want = {
name: 'default',
account: 0,
change: false,
derivation: 'm/0\'/0/0'
};
assert.deepStrictEqual(got, want);
}
{
const got = path.getJSON('regtest');
const want = {
name: 'default',
account: 0,
change: false,
derivation: 'm/44\'/5355\'/0\'/0/0'
};
assert.deepStrictEqual(got, want);
}
});
it('should deserialize path', () => {
const path1 = Path.fromJSON({
name: 'default',
account: 0,
change: true,
derivation: 'm/0\'/1/1'
});
const path2 = new Path().fromJSON({
name: 'default',
account: 0,
change: true,
derivation: 'm/44\'/5355\'/0\'/1/1'
});
assert.deepStrictEqual(path1, path2);
const got = path1;
const want = new Path();
want.name = 'default';
want.account = 0;
want.branch = 1;
want.index = 1;
assert.deepStrictEqual(got, want);
});
});