Page MenuHomePhabricator

[marlin] Add end to end tests for the transaction history screen
ClosedPublic

Authored by Fabien on Apr 9 2026, 14:40.

Details

Summary

It involves mocking the chronik API and intercepting the requests. In order to do so a script (export-chronik-stub.ts) is added to generate a json mock which is later transformed into the expected protobuf chronik response, so the tests run offline.

Depends on D19802.

Test Plan
pnpm run test:e2e

Diff Detail

Repository
rABC Bitcoin ABC
Branch
marlin_transaction_history_test
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 36572
Build 72587: Build Diffmarlin-wallet-e2e-tests · marlin-wallet · marlin-wallet-tests
Build 72586: arc lint + arc unit

Event Timeline

Fabien requested review of this revision.Apr 9 2026, 14:40
bytesofman added a subscriber: bytesofman.
bytesofman added inline comments.
apps/marlin-wallet/web/cypress/fixture/chronik/qqa9lv3kjd8vq7952p7rq0f6lkpqvlu0cydvxtd70g.json
14 ↗(On Diff #58957)

why are the encodings not "the same" as results we could expect from chronik-client?

Seems like this makes it harder to generate mocks.

update: ok after reviewing i see what's going on, so in this way you can mock the actual endpoint responses, works well with cy intercept

this is still pretty complicated; what was your procedure for generating these mocks?

A possible alt approach would be to use MockChronikClient and set it as it is usually set before tests. But depending on architecture, this can be quite difficult to drop in / inject in place of chronik in the tests.

The intercept approach is probably a better pure API reflection. Maybe add scripts / tools to generate these into modules/mock-chronik-client?

update: ok I see how these are generated, nice. For now, cypress is only being used in marlin, so it makes sense to keep the scripts here vs in mock-chronik-client. As the stubbing system matures / if it becomes more complex and starts getting more endpoints, could consider adding these scripts to their own dir in the monorepo, or perhaps to mock-chronik-client.

Chronik's strongly-typed responses are super helpful for creating detailed real world tests. But the mock creation across various testing libs is a huge headache (see Cashtab, here). Now that AI is commonly available, even some MD files or context where prompts like "please create appropriate mocks for a wallet with this balance including this token balance and this kind of tx history" would be ideal.

47 ↗(On Diff #58957)

these are different encodings vs normal hex?

why?

This revision is now accepted and ready to land.Apr 9 2026, 15:06
apps/marlin-wallet/web/cypress/fixture/chronik/qqa9lv3kjd8vq7952p7rq0f6lkpqvlu0cydvxtd70g.json
14 ↗(On Diff #58957)

The trivial approach would be to store everything as a binary protobuf response, but this makes the files impossible to review. So I had to go through this whole machinery.

Using a mock will not work with cypress because it's loading the real "website", aka the webpack bundle. That was my initial idea: mocking ecash-wallet to get what I want easily but this will not work with this test methodology, so I had to mock the chronik I/Os and use cypress intercept function.

The script could move to mock-chronik-client later if needed, no issue it doesn't depend on this project. I made it so it takes an address and dump the history and txs from that address. This makes it easy to create a test wallet via Cashtab or Marlin, dump it to a stub file then send the funds back to you. Doing so you can "snapshot" the wallet state, leak the mnemonic (so you can sign txs) and not get your funds moved by somebody else.

47 ↗(On Diff #58957)

protobuf bytes type translate to base64 when using toJSON/fromJSON

Rename the txid hex conversion function