-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpublic-key-tests.js
29 lines (28 loc) · 1.41 KB
/
public-key-tests.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
const { expect } = require('chai')
.use(require('chai-bytes'));
const { toHex, getApplication, removeMasterNode } = require('./helpers/common');
const { TEST_DATA } = require('./helpers/data');
const { authTokenFlows } = require('./helpers/flow');
describe("Public Key Tests", function () {
context("Public Key Commands", function () {
authTokenFlows("can get extended public key")
.init(async ({test, auth}) => {
const account = TEST_DATA.account;
const flow = [{ header: null, body: 'Ext PubKey Export' },
{ header: 'Path', body: removeMasterNode(account.path.toString()) }];
if (auth) {
flow.push({ header: 'Application', body: getApplication(test.device) });
}
flow.push({ header: null, body: 'Approve' }, { header: null, body: 'Reject' });
return { account, flow, flowsCount: 1 };
})
.shouldSucceed(({flow, flows, account}, extPubKey) => {
expect(flows[0]).to.be.deep.equal(flow);
expect(extPubKey).to.be.deep.equal({
publicKey: toHex(account.publicKey.pub_key_bytes()),
chainCode: toHex(account.publicKey.chain_code()),
});
})
.run(({test, account}) => test.device.getExtendedPublicKey(account.path.toString()));
});
});