Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/multimodal/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ def test_shm_receiver_requires_sender_handle_for_current_cache_key():

try:
sender_item, _ = sender_cache.get_and_update_item((item, []), mm_hash)
assert sender_item is not None

valid_feature = MultiModalFeatureSpec(
data=sender_item,
Expand Down Expand Up @@ -897,12 +898,16 @@ def test_shm_sender_validates_client_supplied_handles():
handle, _ = sender_cache.get_and_update_item(
(MultiModalKwargsItem.dummy(1024), []), mm_hash
)
assert handle is not None
sender_cache.validate_input_item(handle, mm_hash)
sender_cache.validate_input_item(MultiModalKwargsItem.dummy(16), mm_hash)

signature = handle["signature"].data
assert isinstance(signature, list) and signature
first_byte = signature[0]
assert isinstance(first_byte, int)
forged = [
_with_elem(handle, "signature", [signature[0] ^ 1, *signature[1:]]),
_with_elem(handle, "signature", [first_byte ^ 1, *signature[1:]]),
_with_elem(handle, "signature", [signature]),
_with_elem(handle, "address", True),
_with_elem(handle, "address", -1),
Expand Down Expand Up @@ -934,6 +939,7 @@ def test_shm_receiver_rejects_out_of_range_handle_fields():
handle, _ = sender_cache.get_and_update_item(
(MultiModalKwargsItem.dummy(1024), []), mm_hash
)
assert handle is not None and "signature" in handle
for key, value in [
("address", -1),
("address", 2**64),
Expand Down Expand Up @@ -967,6 +973,7 @@ def feature(data: MultiModalKwargsItem) -> MultiModalFeatureSpec:

try:
stale_item, _ = sender_cache.get_and_update_item((item, []), mm_hash)
assert stale_item is not None and "signature" in stale_item
sender_cache.clear_cache()

# A request still draining after the clear resolves to its own data.
Expand Down
Loading