refactor(vaults): move the settle rules, vault writer, stored tally and server-vault push into the key ledger

This commit is contained in:
imSp4rky
2026-12-04 14:07:04 -07:00
parent 67dea28712
commit 8c4742c0ee
8 changed files with 313 additions and 122 deletions
+2 -20
View File
@@ -416,26 +416,6 @@ def test_a_cdm_that_confirms_a_key_flagged_on_entry_clears_the_flag(
assert CONFIRMED in caplog.record_tuples
def test_a_licence_key_that_replaces_a_bad_local_pair_is_stored(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""The local vault held the bad pair when the licence key arrived, so it skipped the KID; store it now."""
local = SQLite("local", tmp_path / "local.db")
local.add_key("SVC", KID, BAD)
vaults = Vaults("SVC")
vaults.vaults = [local]
keys = make_resolver(monkeypatch, vaults)
drm = FakeDRM({KID: vaults.get_key(KID)[0]})
path = tmp_path / "video.mp4"
path.write_bytes(b"cipher")
assert local.add_keys("SVC", {KID: GOOD}) == 0
keys.decrypt_verified(drm, path, lambda drm, track_kid: drm.content_keys.update({KID: GOOD}), KID)
keys.wait_vault_writes()
assert local.is_bad_key(KID, BAD)
assert local.get_key(KID, "SVC") == GOOD
def test_stale_backup_from_a_killed_run_is_not_restored(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
poisoned = Remote("poisoned", tmp_path / "poisoned.db")
poisoned.add_key("SVC", KID, BAD)
@@ -901,6 +881,7 @@ def test_api_vault_reports_the_pair_upstream(monkeypatch: pytest.MonkeyPatch, ca
vaults.flag_bad_key(KID, BAD)
assert not calls
vaults.proven({KID: GOOD}, {})
vaults.wait_writes()
vaults.unflag_bad_key(KID, BAD)
assert calls == [
@@ -912,6 +893,7 @@ def test_api_vault_reports_the_pair_upstream(monkeypatch: pytest.MonkeyPatch, ca
vaults.supplied(KID, BAD, source) # type: ignore[arg-type]
vaults.flag_bad_key(KID, BAD)
vaults.proven({KID: GOOD}, {})
vaults.wait_writes()
calls.clear()
flag_and_replace(SimpleNamespace(name="other", local=False, report_now=False))