mineracks-ckbunker-hsm-sign/tests/test_05_rule1_with_totp_signs.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

21 lines
686 B
Python

"""Rule #1 equivalent: with a fresh TOTP code the same large PSBT signs."""
import pytest
from ckbunker_hsm_sign import Client, SignStatus
from ckbunker_hsm_sign.config import Config
@pytest.mark.asyncio
async def test_large_psbt_signs_with_totp(client: Client, large_psbt: bytes, cfg: Config):
if not cfg.totp_secret:
pytest.skip("TOTP_SECRET not configured")
async with client.session() as session:
res = await session.sign_psbt(large_psbt, use_totp=True)
assert res.status == SignStatus.SIGNED, (
f"expected SIGNED, got {res.status.value}: {res.reason or res.error}"
)
assert res.signed_bytes and res.signed_bytes[:5] == b"psbt\xff"