Page MenuHomePhabricator

[mock-chronik-client] Publish as npm pkg and install where used
ClosedPublic

Authored by bytesofman on Mar 2 2024, 23:34.

Details

Summary

This library is used extensively enough, even if just internally, to merit publishing. This will simplify its use from different dir levels of the monorepo and also allow it to become more complex (i.e. use dependencies like ecashaddrjs).

While running regtest integrations is the "best" way to solve some testing problems, there is still a place for this as a dev tool.

Will move it to modules/ and set up automated npm publishing in later diffs.

Test Plan

CI will run npm test in impacted modules

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: useWallet hook rendering in different localforage states Cashtab loads wallet, settings, cache, and contactlist from localforage to context if they are present ======
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 7
+ Received  + 0

@@ -1,14 +1,7 @@
  Object {
    "tokens": Map {
-     "1f6a65e7a4bde92c0a012de2bcf4007034504a765377cdf08a3ee01d1eaa6901" => Object {
-       "decimals": 0,
-       "tokenDocumentHash": "",
-       "tokenDocumentUrl": "",
-       "tokenName": "Burger",
-       "tokenTicker": "  ",
-     },
      "3fee3384150b030490b7bee095a63900f66a45f2d8e3002ae2cf17ce3ef4d109" => Object {
        "decimals": 0,
        "success": true,
        "tokenDocumentHash": "",
        "tokenDocumentUrl": "https://cashtab.com/",

Ignored nodes: comments, script, style
<html>
  <head />
  <body>
    <div />
  </body>
</html>
    at toStrictEqual (/work/cashtab/src/hooks/__tests__/useWallet.test.js:103:62)
    at runWithExpensiveErrorDiagnosticsDisabled (/work/cashtab/node_modules/@testing-library/dom/dist/config.js:47:12)
    at checkCallback (/work/cashtab/node_modules/@testing-library/dom/dist/wait-for.js:124:77)
    at checkRealTimersCallback (/work/cashtab/node_modules/@testing-library/dom/dist/wait-for.js:118:16)
    at Timeout.task [as _onTimeout] (/work/cashtab/node_modules/jsdom/lib/jsdom/browser/Window.js:520:19)
    at listOnTimeout (node:internal/timers:573:17)
    at processTimers (node:internal/timers:514:7)

Each failure log is accessible here:
CashTab Unit Tests: useWallet hook rendering in different localforage states Cashtab loads wallet, settings, cache, and contactlist from localforage to context if they are present

bytesofman published this revision for review.Mar 2 2024, 23:56
This revision is now accepted and ready to land.Mar 3 2024, 03:41

Some more thoughts on this one

The issue before: when CI is run for the other repos, it is not running npm ci on mock-chronik-client but on itself, e.g. for alias-server or ecash-herald. We could modify all the other CIs to also install it for mock-chronik-client.

Tempting to just fix it by getting other CIs to install deps for mock-chronik-client before running. The workflow is a little easier than having to install a new npm pkg on all these other dependencies.

I think though if mock-chronik-client is important enough to use in so many of our repos, it is important enough to be its own package. We can get the same "test all CI" impact by installing the newest version everywhere it is intended to be used. So, will impact workflow of diffs to improve chronik-client somewhat. But imo it is more useful as a published package, so worth it.