-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaddress-tests.js
47 lines (45 loc) · 2.31 KB
/
address-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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { expect } = require('chai')
.use(require('chai-bytes'));
const { toHex, getApplication, removeMasterNode } = require('./helpers/common');
const { TEST_DATA } = require('./helpers/data');
const { mergePagedScreens } = require("./helpers/screen");
const { authTokenFlows } = require('./helpers/flow');
describe("Address Tests", function () {
context("Address Commands", function () {
authTokenFlows("can derive address")
.init(async ({test, auth}) => {
const address = TEST_DATA.address0;
const flow = [{ header: null, body: 'Confirm Send Address' },
{ header: 'Path', body: removeMasterNode(address.path.toString()) }];
if (auth) {
flow.push({ header: 'Application', body: getApplication(test.device) })
}
flow.push({ header: null, body: 'Approve' }, { header: null, body: 'Reject' });
return { address, flow, flowsCount: 1 };
})
.shouldSucceed(({flow, flows, address}, derived) => {
expect(flows[0]).to.be.deep.equal(flow);
expect(derived).to.be.deep.equal({
addressHex: toHex(address.toBytes())
});
})
.run(({test, address}) => test.device.deriveAddress(address.path.toString()));
authTokenFlows("can show address")
.init(async ({test, auth}) => {
const address = TEST_DATA.address0;
const flow = [{ header: null, body: 'Confirm Address' },
{ header: 'Path', body: removeMasterNode(address.path.toString()) },
{ header: 'Address', body: address.toBase58() }];
if (auth) {
flow.push({ header: 'Application', body: getApplication(test.device) })
}
flow.push({ header: null, body: 'Approve' }, { header: null, body: 'Reject' });
return { address, flow, flowsCount: 1 };
})
.shouldSucceed(({flow, flows}, show) => {
expect(mergePagedScreens(flows[0])).to.be.deep.equal(flow);
expect(show).to.be.true;
})
.run(({test, address}) => test.device.showAddress(address.path.toString()));
});
});