Skip to content

Commit ccfc5f7

Browse files
committed
fix(ledgerjs): Update tests and use nano x
1 parent c12d044 commit ccfc5f7

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

.github/workflows/_ledgernano.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828

2929
- name: Download ledgernano binary
3030
run: |
31-
curl -L -o nanos.tar.gz https://github.com/iotaledger/ledger-app-iota/releases/download/ledger-app-iota-v0.9.2/nanos.tar.gz
32-
tar -xvf nanos.tar.gz
33-
mv nanos/iota sdk/ledgerjs-hw-app-iota/tests/iota
31+
curl -L -o nanox.tar.gz https://github.com/iotaledger/ledger-app-iota/releases/download/ledger-app-iota-v0.9.2/nanox.tar.gz
32+
tar -xvf nanox.tar.gz
33+
mv nanox/iota sdk/ledgerjs-hw-app-iota/tests/iota
3434
3535
- name: Start speculos simulator
3636
run: docker run --rm -d -p 5000:5000 -v $(pwd)/sdk/ledgerjs-hw-app-iota/tests:/app ghcr.io/ledgerhq/speculos --api-port 5000 --display headless /app/iota

sdk/ledgerjs-hw-app-iota/tests/Iota.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const SPECULOS_BASE_URL: string = `http://127.0.0.1:${API_PORT}`;
1313

1414
// Before running the tests you need to install speculos and start the iota app with it.
1515
// If the binary is not available, download it:
16-
// gh release download --repo https://github.com/iotaledger/ledger-app-iota -p nanos.tar.gz ledger-app-iota-v0.9.2
17-
// tar -xvf nanos.tar.gz
16+
// gh release download --repo https://github.com/iotaledger/ledger-app-iota -p nanox.tar.gz ledger-app-iota-v0.9.2
17+
// tar -xvf nanox.tar.gz
1818
// sudo apt-get install qemu-user-static libxcb-xinerama0 // might be needed for speculos to work
1919
// pip install speculos
2020
// Finally to start the emulator:
@@ -38,7 +38,7 @@ describe.sequential('Test ledgerjs-hw-app-iota', () => {
3838
);
3939
});
4040

41-
it('Test address generation with display', async () => {
41+
it('Test address generation with display', { timeout: 10000 }, async () => {
4242
const transport = await SpeculosHttpTransport.open({});
4343
const ledgerClient = new Iota(transport);
4444

@@ -55,18 +55,18 @@ describe.sequential('Test ledgerjs-hw-app-iota', () => {
5555
.catch((err) => {
5656
throw new Error(err);
5757
});
58-
await new Promise((resolve) => setTimeout(resolve, 1000));
5958
// Send requests to approve the shown address
60-
for (let i = 0; i < 6; i++) {
59+
for (let i = 0; i < 3; i++) {
6160
await Axios.post(SPECULOS_BASE_URL + '/button/right', { action: 'press-and-release' });
6261
}
6362
await Axios.post(SPECULOS_BASE_URL + '/button/both', { action: 'press-and-release' });
63+
await new Promise((r) => setInterval(r, 4000));
6464
if (!addressReceived) {
6565
throw new Error(`Didn't receive address in time`);
6666
}
6767
});
6868

69-
it('Test signing', { timeout: 10000 }, async () => {
69+
it('Test signing', { timeout: 20000 }, async () => {
7070
const transport = await SpeculosHttpTransport.open({});
7171
const ledgerClient = new Iota(transport);
7272
let signatureReceived = false;
@@ -91,20 +91,19 @@ describe.sequential('Test ledgerjs-hw-app-iota', () => {
9191
});
9292
await new Promise((resolve) => setTimeout(resolve, 500));
9393
// Send requests to approve the tx
94-
for (let i = 0; i < 14; i++) {
94+
for (let i = 0; i < 7; i++) {
9595
await Axios.post(SPECULOS_BASE_URL + '/button/right', { action: 'press-and-release' });
9696
}
9797
await Axios.post(SPECULOS_BASE_URL + '/button/both', { action: 'press-and-release' });
98-
await new Promise((resolve) => setTimeout(resolve, 2000));
98+
await new Promise((resolve) => setTimeout(resolve, 6000));
9999
if (!signatureReceived) {
100100
throw new Error(`Didn't receive signature in time`);
101101
}
102102
});
103103

104-
it('Test blind signing', { timeout: 10000 }, async () => {
104+
it('Test blind signing', { timeout: 20000 }, async () => {
105105
// Enable blind signing
106106
await Axios.post(SPECULOS_BASE_URL + '/button/right', { action: 'press-and-release' });
107-
await Axios.post(SPECULOS_BASE_URL + '/button/right', { action: 'press-and-release' });
108107
await Axios.post(SPECULOS_BASE_URL + '/button/both', { action: 'press-and-release' });
109108
await Axios.post(SPECULOS_BASE_URL + '/button/both', { action: 'press-and-release' });
110109
await Axios.post(SPECULOS_BASE_URL + '/button/right', { action: 'press-and-release' });
@@ -134,11 +133,12 @@ describe.sequential('Test ledgerjs-hw-app-iota', () => {
134133
});
135134
await new Promise((resolve) => setTimeout(resolve, 500));
136135
// Send requests to approve the tx
137-
for (let i = 0; i < 8; i++) {
136+
await Axios.post(SPECULOS_BASE_URL + '/button/both', { action: 'press-and-release' });
137+
for (let i = 0; i < 3; i++) {
138138
await Axios.post(SPECULOS_BASE_URL + '/button/right', { action: 'press-and-release' });
139139
}
140140
await Axios.post(SPECULOS_BASE_URL + '/button/both', { action: 'press-and-release' });
141-
await new Promise((resolve) => setTimeout(resolve, 2000));
141+
await new Promise((resolve) => setTimeout(resolve, 6000));
142142
if (!signatureReceived) {
143143
throw new Error(`Didn't receive signature in time`);
144144
}

0 commit comments

Comments
 (0)