test(pair-endpoint): update stale pair_spire double + mock get_super_config

The pairing endpoint tests' fake_pair predated the bunker_relay parameter
(views_api passes bunker_relay=data.bunker_relay), so it raised TypeError; and
api_pair_machine later grew a get_super_config() read for the post-pair fee
publish that the doubles never mocked, hitting a DB with no spirekeeper.super_config
table. Both were pre-existing failures on main (masked one behind the other).

Add bunker_relay to the fake_pair signature and mock get_super_config → None
(the happy path doesn't exercise fee publishing). Suite green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-07-01 21:16:10 +02:00
commit b93e3fb698

View file

@ -66,7 +66,9 @@ def _wire(monkeypatch, *, pair="ok"):
async def fake_owned(machine_id, user_id):
return _machine()
async def fake_pair(machine, *, relays, admin_client, duration_hours=None):
async def fake_pair(
machine, *, relays, admin_client, bunker_relay=None, duration_hours=None
):
if pair == "error":
raise PairingError("boom")
return _result()
@ -80,11 +82,18 @@ def _wire(monkeypatch, *, pair="ok"):
state["persisted"] = (machine_id, machine_npub, bunker_spire_key_name)
return _machine(npub=machine_npub)
# After pairing, the endpoint reads super_config to publish fee config
# (soft-fail tail). None short-circuits it — the happy-path assertions
# don't exercise fee publishing, and it keeps the test off the DB.
async def fake_super_config():
return None
monkeypatch.setattr(views_api, "_machine_owned_by", fake_owned)
monkeypatch.setattr(views_api, "NsecBunkerAdminClient", _FakeAdmin)
monkeypatch.setattr(views_api, "pair_spire", fake_pair)
monkeypatch.setattr(views_api, "_assert_no_pubkey_collision", fake_collision)
monkeypatch.setattr(views_api, "set_machine_pairing", fake_persist)
monkeypatch.setattr(views_api, "get_super_config", fake_super_config)
return state