Page MenuHomePhabricator

[chronik] Fix running chronik tests when websocket is not installed
Needs RevisionPublic

Authored by sdulfari on Apr 19 2023, 18:29.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Summary

D13691 introduced the websocket dependency that may not be installed on all environments. For example it is unexpected to have this installed when chronik is not enabled in the build.

Test Plan

Without websockets installed:

ninja
./test/functional/test_runner.py chronik_*

The test should all be skipped instead of failing.

@bot build-chronik on CI

Diff Detail

Repository
rABC Bitcoin ABC
Branch
fix-chronik-tests-when-disabled
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23375
Build 46369: Build Diffbuild-without-wallet · build-diff · build-debug · build-clang-tidy · build-clang
Build 46368: arc lint + arc unit

Event Timeline

sdulfari updated this revision to Diff 39816.

Fixup comment

sdulfari retitled this revision from [chronik] Fix running chronik tests when websockets is not installed to [chronik] Fix running chronik tests when websocket is not installed.Apr 19 2023, 18:31
sdulfari edited the summary of this revision. (Show Details)

OK, this works because websocket is never used in this module at import time, only at runtime when a ChronikClient instance is created and used.

It will cause a non-descriptive error at runtime if chronik is compiled, when the tests are not skipped, though. We could add a more descriptive error message (see inline comments)

test/functional/test_framework/chronik/client.py
13

(If mypy allows this)

141
Fabien requested changes to this revision.Apr 21 2023, 10:44
Fabien added a subscriber: Fabien.

That's not a good solution. We want to only include chronik/client.py if chronik is built, then whatever other dependency loaded from there is expected to be installed. This is the same for every other dev dependency: we expect the devs to be able to figure out they didn't read the doc and are missing the dependency.
The root cause is this client file being loaded if chronik is not built, and this is what needs to be fixed. This will also make the protobuf import simple (no longer needing the function wrapper).

This revision now requires changes to proceed.Apr 21 2023, 10:44