Skip to content

LLD:DeepLinking:TestAndDebug

Clément Pellizzari edited this page Jun 12, 2023 · 5 revisions

Testing and debugging deep linking in LLD - efficiently, but not usable for integration testing

-> go this way when you are in active dev of the deeplink & debugging to have quick iterations

In the devtools console :

let remote = require('@electron/remote')
let win = remote.getCurrentWindow()
win.send('deep-linking','ledgerlive://what/you/want')

Testing and debugging deep linking in LLD - the painful way

-> go this way when it mostly works, but you want to test/debug real integration.

In order to test (and debug) deep linking on LLD, you need to build the app (except if you are on windows theoretically), cf. this page from the Electron doc.

You will also need to replace your installed Ledger Live version by the locally built one.

Here are the steps (for mac, should be similar for other OS):

  1. build LLD (by running pnpm build:lld at the root of the ledger-live repo)
  2. [OPTIONAL] backup your app.json file located under /Users/[USERNAME]/Library/Application Support/Ledger Live/app.json to another location (just in case)
  3. copy your locally built Ledger Live app to the default Applications folder: \cp -r apps/ledger-live-desktop/dist/mac-universal/Ledger\ Live.app /Applications/
  4. open a deeplink (such as ledgerlive://discover/lido)
  5. this should open the Live on the appropriate page (depending in deeplink used for test)

If you need to debug the behaviour happening with deeplinks, as of today your only tool is logging.

Note: since the app is built and run in prod environement, for your logs to be visible, you need to use logger.log() from ~/logger instead of traditionnal console.log().

Here is a quick step by step guide:

  1. spray the sucpitious code / code you want to investigate with logs
    1. it's best to start from the root of deeplinks, ie: apps/ledger-live-desktop/src/renderer/hooks/useDeeplinking.js
    2. it's best to prefix your logs with a unique / recognisable patter such as "TEST --- " to ease retrieving thems in the logfile
    3. as with any logs, you can add additional objects to check their value logger.log("TEST --- functionA", { objectA });
  2. build the app and test (cf. steps above)
  3. extract the logs from the app (either through the settings or through the "save logs" button of the error screen if the app has crashed)
  4. open the logs file in your favorite editor and search for your debug logs to investigate
  5. rince and repeat until you isolate the root cause of your issue

Note:

One might want to take a deeper look at this issue to enable local developement test and debugging of deeplinks 🔍

Clone this wiki locally