feat: gate_bus mask stash

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 17:35:28 +02:00
parent 9148dfec25
commit 11772bc29d
2 changed files with 18 additions and 0 deletions
+8
View File
@@ -33,3 +33,11 @@ class GateBus:
raise GateCancelled()
time.sleep(period)
return cls.messages.pop(sid)
@classmethod
def put_mask(cls, node_id, data):
cls.masks[str(node_id)] = data
@classmethod
def pop_mask(cls, node_id):
return cls.masks.pop(str(node_id), None)
+10
View File
@@ -26,3 +26,13 @@ def test_arm_clears_stale_state():
gb.GateBus.arm("1")
assert "1" not in gb.GateBus.messages
assert gb.GateBus.cancelled is False
def test_mask_stash_roundtrip():
gb.GateBus.put_mask("9", b"PNGDATA")
assert gb.GateBus.pop_mask("9") == b"PNGDATA"
assert gb.GateBus.pop_mask("9") is None # popped
def test_arm_clears_mask():
gb.GateBus.put_mask("9", b"x")
gb.GateBus.arm("9")
assert gb.GateBus.pop_mask("9") is None