mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
test(matrix): assert real device_id in query_keys, not just guard-skip
Hardens the salvaged #53997 tests per review: the positive-resolution and reconnect-recovery tests now assert query_keys is awaited with the REAL resolved device id ({mxid: [<id>]}) and never [None] — the [null] body the homeserver rejects (the actual bug), plus await_count==2 to prove verification genuinely re-runs after resolution rather than just the flag looking right.
This commit is contained in:
parent
09dbe76955
commit
314cf43d50
1 changed files with 20 additions and 1 deletions
|
|
@ -4816,6 +4816,16 @@ class TestDeviceIdNoneResolution:
|
|||
|
||||
assert result is True
|
||||
assert adapter._device_id_unverified is False
|
||||
# Positive path (W1 hardening, salvage of #53997): the resolution query
|
||||
# must use an empty device list ({mxid: []}), and once RESOLVED_DEV is
|
||||
# adopted the verification query must carry the REAL id, never [None]
|
||||
# (the [null] body Synapse/Dendrite reject — the original bug).
|
||||
assert mock_client.device_id == "RESOLVED_DEV"
|
||||
assert mock_client.query_keys.await_count == 2
|
||||
_resolution_call, _verify_call = mock_client.query_keys.await_args_list
|
||||
assert _resolution_call.args[0] == {"@bot:example.org": []}
|
||||
assert _verify_call.args[0] == {"@bot:example.org": ["RESOLVED_DEV"]}
|
||||
assert None not in _verify_call.args[0]["@bot:example.org"]
|
||||
|
||||
await adapter.disconnect()
|
||||
|
||||
|
|
@ -5247,6 +5257,15 @@ class TestDeviceIdRecoveryOnReconnect:
|
|||
|
||||
assert result is True
|
||||
assert adapter._device_id_unverified is False
|
||||
mock_client2.query_keys.assert_awaited()
|
||||
# Verification must genuinely re-run on the second connect — not just
|
||||
# the resolution query. Two awaited query_keys calls: resolution
|
||||
# ({mxid: []}) then verification ({mxid: [<resolved id>]}). The
|
||||
# verification call must carry the REAL resolved device id ("DEV2"),
|
||||
# never [None] (the original bug). (W2 hardening, salvage of #53997)
|
||||
assert mock_client2.query_keys.await_count == 2
|
||||
_resolution_call, _verify_call = mock_client2.query_keys.await_args_list
|
||||
assert _resolution_call.args[0] == {"@bot:example.org": []}
|
||||
assert _verify_call.args[0] == {"@bot:example.org": ["DEV2"]}
|
||||
assert None not in _verify_call.args[0]["@bot:example.org"]
|
||||
|
||||
await adapter.disconnect()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue