Page MenuHomePhabricator

[Cashtab] Improvements to app handling of new blocks
ClosedPublic

Authored by bytesofman on Apr 4 2024, 13:04.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCdb2e840e6fe7: [Cashtab] Improvements to app handling of new blocks
Summary

Now that we have in-node chronik, we should only be triggering app updates that are block related on avalanche-finalized blocks.

  1. The only app logic using blocks now is aliases. This should be gated by aliasSettings.aliasEnabled -- do this
  2. Add notifications for found blocks. May remove this after halving but might be a nice touch. I like the info.
Test Plan

npm test

desktop:

image.png (84×330 px, 13 KB)

mobile:

image.png (125×380 px, 17 KB)

This diff is deployed at https://cashtab-local-dev.netlify.app/ for live testing

Reminder ancient bitcoin dev law: if you are actively testing something that requires waiting for a block, please expect unusually long block times

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices is null ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: {"note": "alias-server is in beta and these prices are not finalized.", "prices": [{"fees": {"1": 558, "10": 551, "11": 551, "12": 551, "13": 551, "14": 551, "15": 551, "16": 551, "17": 551, "18": 551, "19": 551, "2": 557, "20": 551, "21": 551, "3": 556, "4": 555, "5": 554, "6": 553, "7": 552, "8": 551, "9": 551}, "startHeight": 823950}]}
Received: null
    at Object.toStrictEqual (/work/cashtab/src/wallet/__tests__/useWallet.test.js:263:44)
====== CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices exists, server and cashtab prices array length do not match ======
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 26
+ Received  +  0

@@ -25,33 +25,7 @@
          "8": 551,
          "9": 551,
        },
        "startHeight": 823944,
      },
-     Object {
-       "fees": Object {
-         "1": 558,
-         "10": 551,
-         "11": 551,
-         "12": 551,
-         "13": 551,
-         "14": 551,
-         "15": 551,
-         "16": 551,
-         "17": 551,
-         "18": 551,
-         "19": 551,
-         "2": 557,
-         "20": 551,
-         "21": 551,
-         "3": 556,
-         "4": 555,
-         "5": 554,
-         "6": 553,
-         "7": 552,
-         "8": 551,
-         "9": 551,
-       },
-       "startHeight": 823950,
-     },
    ],
  }
    at Object.toEqual (/work/cashtab/src/wallet/__tests__/useWallet.test.js:392:44)
====== CashTab Unit Tests: useWallet hook rendering in different localforage states Verify a processChronikWsMsg() new block event updates the `aliasServerError` state var upon a /prices/ endpoint error ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: [Error: Invalid response from alias prices endpoint]
Received: false
    at Object.toStrictEqual (/work/cashtab/src/wallet/__tests__/useWallet.test.js:589:49)

Each failure log is accessible here:
CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices is null
CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices exists, server and cashtab prices array length do not match
[[https://build.bitcoinabc.org/viewLog.html?tab=buildLog&logTab=tree&filter=debug&expand=all&buildId=736175&_focus=30551&guest=1 | CashTab Unit Tests: useWallet hook rendering in different localforage states Verify a processChronikWsMsg() new block event updates the aliasServerError state var upon a /prices/ endpoint error]]

bytesofman retitled this revision from [Cashtab] Only pay attention to avalanche finalized blocks and add notifications for halving countdown to [Cashtab] Improvements to app handling of new blocks.Apr 4 2024, 13:12

Failed tests logs:

====== CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices is null ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: {"note": "alias-server is in beta and these prices are not finalized.", "prices": [{"fees": {"1": 558, "10": 551, "11": 551, "12": 551, "13": 551, "14": 551, "15": 551, "16": 551, "17": 551, "18": 551, "19": 551, "2": 557, "20": 551, "21": 551, "3": 556, "4": 555, "5": 554, "6": 553, "7": 552, "8": 551, "9": 551}, "startHeight": 823950}]}
Received: null
    at Object.toStrictEqual (/work/cashtab/src/wallet/__tests__/useWallet.test.js:263:44)
====== CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices exists, server and cashtab prices array length do not match ======
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 26
+ Received  +  0

@@ -25,33 +25,7 @@
          "8": 551,
          "9": 551,
        },
        "startHeight": 823944,
      },
-     Object {
-       "fees": Object {
-         "1": 558,
-         "10": 551,
-         "11": 551,
-         "12": 551,
-         "13": 551,
-         "14": 551,
-         "15": 551,
-         "16": 551,
-         "17": 551,
-         "18": 551,
-         "19": 551,
-         "2": 557,
-         "20": 551,
-         "21": 551,
-         "3": 556,
-         "4": 555,
-         "5": 554,
-         "6": 553,
-         "7": 552,
-         "8": 551,
-         "9": 551,
-       },
-       "startHeight": 823950,
-     },
    ],
  }
    at Object.toEqual (/work/cashtab/src/wallet/__tests__/useWallet.test.js:392:44)
====== CashTab Unit Tests: useWallet hook rendering in different localforage states Verify a processChronikWsMsg() new block event updates the `aliasServerError` state var upon a /prices/ endpoint error ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: [Error: Invalid response from alias prices endpoint]
Received: false
    at Object.toStrictEqual (/work/cashtab/src/wallet/__tests__/useWallet.test.js:589:49)

Each failure log is accessible here:
CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices is null
CashTab Unit Tests: useWallet hook rendering in different localforage states processChronikWsMsg() refreshes alias prices when aliasPrices exists, server and cashtab prices array length do not match
[[https://build.bitcoinabc.org/viewLog.html?tab=buildLog&logTab=tree&filter=debug&expand=all&buildId=736177&_focus=30267&guest=1 | CashTab Unit Tests: useWallet hook rendering in different localforage states Verify a processChronikWsMsg() new block event updates the aliasServerError state var upon a /prices/ endpoint error]]

better param handling, update unit test mocks and calls

remove debug logs, improve text

bytesofman edited the test plan for this revision. (Show Details)

minor version bump

bytesofman edited the test plan for this revision. (Show Details)

do not autoclose THE halving notification

bytesofman published this revision for review.Apr 4 2024, 14:16
This revision is now accepted and ready to land.Apr 4 2024, 23:52