mineracks-ckbunker-hsm-sign/tests/test_06_counters_tracked.py
mineracks 9d380f5013 Initial import: CKBunker HSM validation harness
WebSocket client + CLI harness + pytest suite that exercises each axis of
a CKBunker + Coldcard Mk4 policy and asserts the expected outcomes, including
the critical negative test that a large PSBT without TOTP is rejected with
a specific 'rule #1: need user(s) confirmation' reason.

Configuration via .env / YAML / CLI flags, two pre-crafted test PSBTs as
fixtures (generation guide in fixtures/README.md), dashboard counter
scraper as sanity check, design rationale in docs/.
2026-04-14 10:50:04 +10:00

26 lines
908 B
Python

"""Server-visible counters should reflect the operations just done.
Soft test: if the scraper can't read the dashboard on your CKBunker version,
this skips rather than fails — the real signing tests already prove the
end-to-end path worked.
"""
import pytest
from ckbunker_hsm_sign.config import Config
from ckbunker_hsm_sign.scraper import fetch_counters
def test_counters_read(cfg: Config):
counters = fetch_counters(
cfg.url,
cf_client_id=cfg.cf_client_id,
cf_client_secret=cfg.cf_client_secret,
)
if counters.approvals is None and counters.refusals is None:
pytest.skip("could not parse dashboard counters on this CKBunker version")
assert counters.approvals is None or counters.approvals >= 0
assert counters.refusals is None or counters.refusals >= 0
if counters.amount_spent_btc is not None:
assert counters.amount_spent_btc >= 0