|
|
|
|
@ -252,3 +252,61 @@ def test_bcsq_end_tx_not_duplicated() -> None:
|
|
|
|
|
routing.on_obp_bcsq_received("OBP-ES", tgid, stream_id)
|
|
|
|
|
|
|
|
|
|
assert factory.events == []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_idle_forward_leg_without_end_tx_is_trimmed() -> None:
|
|
|
|
|
"""A forward leg whose VTERM/BCSQ never flagged it must still age out (was leaking one row per call)."""
|
|
|
|
|
routing, factory, clock, protocols = _obp_stack(("OBP-ES",))
|
|
|
|
|
stream_id = bytes_4(0x01020304)
|
|
|
|
|
tgid = bytes_3(213)
|
|
|
|
|
now = clock.time()
|
|
|
|
|
protocols["OBP-ES"].STATUS[stream_id] = _forward_leg(
|
|
|
|
|
peer_id=bytes_4(71411),
|
|
|
|
|
rf_src=bytes_3(2130035),
|
|
|
|
|
tgid=tgid,
|
|
|
|
|
start=now - 6,
|
|
|
|
|
last=now - 6,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
with _patch_wall_time(clock):
|
|
|
|
|
routing.stream_trimmer_loop()
|
|
|
|
|
assert protocols["OBP-ES"].STATUS[stream_id].get("_to") is True
|
|
|
|
|
assert _end_tx_for(factory.events, "OBP-ES") == []
|
|
|
|
|
clock.advance(181)
|
|
|
|
|
routing.stream_trimmer_loop()
|
|
|
|
|
|
|
|
|
|
assert stream_id not in protocols["OBP-ES"].STATUS
|
|
|
|
|
assert len(_end_tx_for(factory.events, "OBP-ES")) == 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_trimmed_obp_stream_releases_talker_alias_state() -> None:
|
|
|
|
|
"""OBP streams have no HBP VTERM hook: per-stream TA and log-once state must go with the row."""
|
|
|
|
|
routing, _factory, clock, protocols = _obp_stack(("OBP-ES",))
|
|
|
|
|
proto = protocols["OBP-ES"]
|
|
|
|
|
cleared: list[bytes] = []
|
|
|
|
|
trims: list[bool] = []
|
|
|
|
|
proto.clear_ta_stream_buffer = cleared.append
|
|
|
|
|
proto.trim_dmra_streams = lambda: trims.append(True)
|
|
|
|
|
stream_id = bytes_4(0x0A0B0C0D)
|
|
|
|
|
other_id = bytes_4(0x0A0B0C0E)
|
|
|
|
|
tgid = bytes_3(213)
|
|
|
|
|
now = clock.time()
|
|
|
|
|
proto.STATUS[stream_id] = _ingress_leg(
|
|
|
|
|
peer_id=bytes_4(71411), rf_src=bytes_3(2130035), tgid=tgid, start=now - 10, last=now - 6,
|
|
|
|
|
)
|
|
|
|
|
routing._passthrough_relayed.add(routing._both_ta_key("OBP-ES", stream_id))
|
|
|
|
|
busy_key = routing._ingress_drop_key("tg_busy", "OBP-ES", bytes_4(71411), tgid, stream_id)
|
|
|
|
|
other_key = routing._ingress_drop_key("tg_busy", "OBP-ES", bytes_4(71411), tgid, other_id)
|
|
|
|
|
routing._ingress_drop_log_cache().update({busy_key, other_key})
|
|
|
|
|
|
|
|
|
|
with _patch_wall_time(clock):
|
|
|
|
|
routing.stream_trimmer_loop()
|
|
|
|
|
clock.advance(181)
|
|
|
|
|
routing.stream_trimmer_loop()
|
|
|
|
|
|
|
|
|
|
assert stream_id not in proto.STATUS
|
|
|
|
|
assert cleared == [stream_id]
|
|
|
|
|
assert trims
|
|
|
|
|
assert routing._both_ta_key("OBP-ES", stream_id) not in routing._passthrough_relayed
|
|
|
|
|
assert busy_key not in routing._ingress_drop_log_cache()
|
|
|
|
|
assert other_key in routing._ingress_drop_log_cache()
|
|
|
|
|
|