forked from input-output-hk/daedalus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
107 changed files
with
4,457 additions
and
3,905 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
!source/ | ||
!features/ | ||
!storybook/ | ||
!hardware-wallet-tests/ | ||
!tests/ | ||
|
||
# Now we ignore all files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import expect from 'expect'; | ||
|
||
import { | ||
createAndRegisterHardwareWalletChannels, | ||
createHardwareWalletConnectionChannel, | ||
initLedgerChannel, | ||
createTestInstructions, | ||
createCardanoAppChannel, | ||
createGetPublicKeyChannel, | ||
ipcRenderer, | ||
} from './utils'; | ||
|
||
export const run = () => { | ||
expect.assertions(3); | ||
|
||
createTestInstructions([ | ||
'Plug Ledger Nano S to your computer', | ||
'Launch Cardano APP on Nano S/Nano X', | ||
'Run the test again with Cardano App opened', | ||
'Export the public key', | ||
]); | ||
|
||
createAndRegisterHardwareWalletChannels(); | ||
|
||
const cardanoAppChannel = createCardanoAppChannel(); | ||
const publicKeyChannel = createGetPublicKeyChannel(); | ||
const hardwareWalletConnectionChannel = | ||
createHardwareWalletConnectionChannel(); | ||
|
||
return new Promise<void>((resolve) => { | ||
hardwareWalletConnectionChannel.onReceive( | ||
async (params: { path: string }) => { | ||
expect(params).toEqual({ | ||
disconnected: expect.any(Boolean), | ||
deviceType: expect.any(String), | ||
deviceId: null, | ||
deviceModel: expect.any(String), | ||
deviceName: expect.any(String), | ||
path: expect.any(String), | ||
product: expect.any(String), | ||
}); | ||
|
||
const cardanoAppChannelReply = await cardanoAppChannel.request( | ||
{ path: params.path }, | ||
ipcRenderer, | ||
ipcRenderer | ||
); | ||
|
||
expect(cardanoAppChannelReply).toEqual({ | ||
minor: expect.any(Number), | ||
major: expect.any(Number), | ||
patch: expect.any(Number), | ||
deviceId: expect.any(String), | ||
}); | ||
|
||
const extendedPublicKey = await publicKeyChannel.request( | ||
{ | ||
path: "1852'/1815'/0'", | ||
// Shelley 1852 ADA 1815 indicator for account '0' | ||
isTrezor: false, | ||
devicePath: params.path, | ||
}, | ||
ipcRenderer, | ||
ipcRenderer | ||
); | ||
|
||
expect(extendedPublicKey).toEqual({ | ||
chainCodeHex: expect.any(String), | ||
publicKeyHex: expect.any(String), | ||
deviceId: expect.any(String), | ||
}); | ||
|
||
resolve(); | ||
} | ||
); | ||
|
||
initLedgerChannel(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import expect from 'expect'; | ||
|
||
import { | ||
createAndRegisterHardwareWalletChannels, | ||
createHardwareWalletConnectionChannel, | ||
initLedgerChannel, | ||
createTestInstructions, | ||
createGetPublicKeyChannel, | ||
ipcRenderer, | ||
requestLaunchingCardanoAppOnLedger, | ||
} from './utils'; | ||
|
||
export const run = () => { | ||
expect.assertions(3); | ||
|
||
createTestInstructions([ | ||
'Start test runner', | ||
'Plug Ledger Nano S to your computer', | ||
'Start Cardano APP on Nano S', | ||
'Nano S will prompt to export the public key', | ||
'Export the public key', | ||
]); | ||
|
||
createAndRegisterHardwareWalletChannels(); | ||
|
||
const publicKeyChannel = createGetPublicKeyChannel(); | ||
const hardwareWalletConnectionChannel = | ||
createHardwareWalletConnectionChannel(); | ||
|
||
return new Promise<void>((resolve) => { | ||
hardwareWalletConnectionChannel.onReceive( | ||
async (params: { path: string }) => { | ||
expect(params).toEqual({ | ||
disconnected: expect.any(Boolean), | ||
deviceType: expect.any(String), | ||
deviceId: null, | ||
deviceModel: expect.any(String), | ||
deviceName: expect.any(String), | ||
path: expect.any(String), | ||
product: expect.any(String), | ||
}); | ||
|
||
const cardanoAppChannelResponse = | ||
await requestLaunchingCardanoAppOnLedger(params.path); | ||
|
||
expect(cardanoAppChannelResponse).toEqual({ | ||
minor: expect.any(Number), | ||
major: expect.any(Number), | ||
patch: expect.any(Number), | ||
deviceId: expect.any(String), | ||
}); | ||
|
||
const extendedPublicKey = await publicKeyChannel.request( | ||
{ | ||
path: "1852'/1815'/0'", | ||
// Shelley 1852 ADA 1815 indicator for account '0' | ||
isTrezor: false, | ||
devicePath: params.path, | ||
}, | ||
ipcRenderer, | ||
ipcRenderer | ||
); | ||
|
||
expect(extendedPublicKey).toEqual({ | ||
chainCodeHex: expect.any(String), | ||
publicKeyHex: expect.any(String), | ||
deviceId: expect.any(String), | ||
}); | ||
|
||
resolve(); | ||
} | ||
); | ||
|
||
initLedgerChannel(); | ||
}); | ||
}; |
52 changes: 52 additions & 0 deletions
52
hardware-wallet-tests/connect-multiple-hardware-wallets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import expect from 'expect'; | ||
|
||
import { | ||
createAndRegisterHardwareWalletChannels, | ||
createHardwareWalletConnectionChannel, | ||
createSequentialResult, | ||
initLedgerChannel, | ||
createTestInstructions, | ||
waitForZombieMessages, | ||
} from './utils'; | ||
|
||
export const run = () => { | ||
expect.assertions(2); | ||
|
||
createAndRegisterHardwareWalletChannels(); | ||
|
||
const hardwareWalletConnectionChannel = | ||
createHardwareWalletConnectionChannel(); | ||
|
||
createTestInstructions([ | ||
'Start test runner', | ||
'Plug Ledger Nano S to your computer', | ||
'Plug Ledger Nano X to your computer', | ||
]); | ||
|
||
const getNextExpectedSequence = createSequentialResult([ | ||
{ | ||
disconnected: false, | ||
deviceModel: 'nanoS', | ||
}, | ||
{ | ||
disconnected: false, | ||
deviceModel: 'nanoX', | ||
}, | ||
]); | ||
|
||
return new Promise<void>((resolve) => { | ||
hardwareWalletConnectionChannel.onReceive( | ||
async (message: { path: string; deviceModel: string }) => { | ||
const [expectedValue, isOver] = getNextExpectedSequence(); | ||
expect(message).toEqual(expectedValue); | ||
|
||
if (isOver) { | ||
await waitForZombieMessages(); | ||
resolve(); | ||
} | ||
} | ||
); | ||
|
||
initLedgerChannel(); | ||
}); | ||
}; |
62 changes: 62 additions & 0 deletions
62
hardware-wallet-tests/disconnect-multiple-hardware-wallets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import expect from 'expect'; | ||
|
||
import { | ||
createAndRegisterHardwareWalletChannels, | ||
createHardwareWalletConnectionChannel, | ||
createSequentialResult, | ||
initLedgerChannel, | ||
createTestInstructions, | ||
waitForZombieMessages, | ||
} from './utils'; | ||
|
||
const getNextExpectedSequence = createSequentialResult([ | ||
{ | ||
disconnected: false, | ||
deviceModel: 'nanoS', | ||
}, | ||
{ | ||
disconnected: false, | ||
deviceModel: 'nanoX', | ||
}, | ||
{ | ||
disconnected: true, | ||
deviceModel: 'nanoS', | ||
}, | ||
{ | ||
disconnected: true, | ||
deviceModel: 'nanoX', | ||
}, | ||
]); | ||
|
||
export const run = () => { | ||
expect.assertions(4); | ||
|
||
createAndRegisterHardwareWalletChannels(); | ||
|
||
const hardwareWalletConnectionChannel = | ||
createHardwareWalletConnectionChannel(); | ||
|
||
createTestInstructions([ | ||
'Connect Nano S', | ||
'Connect Nano X', | ||
'Disconnect Nano S', | ||
'Disconnect Nano X', | ||
]); | ||
|
||
return new Promise<void>((resolve) => { | ||
hardwareWalletConnectionChannel.onReceive( | ||
async (params: { path: string; deviceModel: string }) => { | ||
const [expectedValue, isOver] = getNextExpectedSequence(); | ||
|
||
expect(params).toEqual(expectedValue); | ||
|
||
if (isOver) { | ||
await waitForZombieMessages(); | ||
return resolve(); | ||
} | ||
} | ||
); | ||
|
||
initLedgerChannel(); | ||
}); | ||
}; |
49 changes: 49 additions & 0 deletions
49
hardware-wallet-tests/disconnect-single-hardware-wallet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import expect from 'expect'; | ||
|
||
import { | ||
createAndRegisterHardwareWalletChannels, | ||
createHardwareWalletConnectionChannel, | ||
initLedgerChannel, | ||
createTestInstructions, | ||
createSequentialResult, | ||
waitForZombieMessages, | ||
} from './utils'; | ||
|
||
export const run = () => { | ||
expect.assertions(3); | ||
|
||
createTestInstructions([ | ||
'Plug Ledger Nano S to your computer', | ||
'Disconnect Nano S', | ||
]); | ||
|
||
createAndRegisterHardwareWalletChannels(); | ||
|
||
const hardwareWalletConnectionChannel = | ||
createHardwareWalletConnectionChannel(); | ||
|
||
const getNextExpectedSequence = createSequentialResult([ | ||
{ | ||
disconnected: false, | ||
}, | ||
{ | ||
disconnected: true, | ||
}, | ||
]); | ||
|
||
return new Promise<void>((resolve) => { | ||
hardwareWalletConnectionChannel.onReceive( | ||
async (params: { path: string }) => { | ||
const [expectedValue, isOver] = getNextExpectedSequence(); | ||
expect(params).toEqual(expectedValue); | ||
|
||
if (isOver) { | ||
await waitForZombieMessages(); | ||
return resolve(); | ||
} | ||
} | ||
); | ||
|
||
initLedgerChannel(); | ||
}); | ||
}; |
Oops, something went wrong.