[QA] Add tests for payload handler - #73
Merged
Merged
Conversation
Haralishev77
requested changes
Mar 20, 2026
mayaparov
force-pushed
the
feature/test-payload-handler
branch
from
March 22, 2026 21:25
dfc035e to
22a3042
Compare
Haralishev77
self-requested a review
March 23, 2026 12:46
Haralishev77
approved these changes
Mar 23, 2026
Haralishev77
added a commit
that referenced
this pull request
Jul 21, 2026
Co-authored-by: Khoroshilov Grigoriy <khorogri@gmail.com>
meaning-0f-life
pushed a commit
to meaning-0f-life/OpenCDA
that referenced
this pull request
Jul 25, 2026
Co-authored-by: Khoroshilov Grigoriy <khorogri@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add deterministic unit tests for
PayloadHandler(OpenCDA ↔ Artery payload building/parsing) using fully stubbed protobuf modules and controlled imports, keeping the suite CI-friendly and independent fromprotocoutput at runtime.This PR contains tests only and does not modify
payload_handler.py.Motivation
PayloadHandleris responsible for assembling outgoing OpenCDA messages and decoding incoming Artery messages. The logic is stateful (it accumulates per-tick data) and relies on serialization (pickle) to transport structured dictionaries through protobuf byte fields. This is easy to break silently during refactors.Additionally, the module imports protobuf code at import time and mutates
sys.path, which makes naive unit tests fragile and dependent on whether generated*_pb2.pyfiles exist locally. The goal of this PR is to lock down contract-level behavior with fast unit tests that run in minimal CI environments.Changes
New unit tests
opencda/core/common/communication/test/test_payload_handler.pyadds contract-level tests for:handle_opencda_payload,handle_artery_payload):make_opencda_message():auxillaryis bytes-like and decodes back to the original per-entity dict viapickle.loads(without comparing raw pickle bytes).make_artery_payload():(ego_id, entity_id)as expected for dict-based storage;clear_messages():Notes on planned changes
The current implementation uses
picklefor serialization. If the project later replacespicklewith a safer serialization format, these unit tests will need to be updated accordingly (the tests intentionally assert decoded content, not raw serialized bytes).How to run