Page MenuHomePhabricator

[alias-server] Chronik functions take chronik as a param to support future mocking
ClosedPublic

Authored by bytesofman on Apr 6 2023, 13:26.

Details

Summary

T3060

Depends on D13592

This diff refactors chronik calling functions to accept chronik as a param.

Will introduce a mock chronik object for unit tests of chronik functions.

Test Plan

npm test
npm run mocks and mocks are generated

Diff Detail

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

Event Timeline

Fabien added inline comments.
apps/alias-server/scripts/generateMocks.js
23 ↗(On Diff #39345)

remove

apps/alias-server/test/chronikTests.js
34 ↗(On Diff #39345)

I don't understand how this work, can you explain why the test doesn't crash ?

bytesofman marked an inline comment as done.

remove console.log(chronik)

apps/alias-server/test/chronikTests.js
34 ↗(On Diff #39345)

See just pushed up diff, D13602

Before chronik is mocked, I am using this optionalMocks param as a sort of isUnitTest flag. It modifies the logic of getUnprocessedTxs such that it does not use chronik for anything.

This revision is now accepted and ready to land.Apr 6 2023, 14:52