Repository navigation
Conversation
) When the VEN has exactly one event and it is completed, order_events returns the list it was given. Popping the completed event from self.events then also emptied the list used for the response, so the VEN received no event. The response is now built from a copy. Adds regression tests. Fixes OpenLEADR#175 Signed-off-by: Engr. Muhammad Fahad <muhammadfahadx2.0@gmail.com>
This branch has not been deployed
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.
Fixes #175
The problem
When a VEN polls and the VTN holds exactly one event for it, and that event is completed, the oadrDistributeEvent response contains an empty
eventslist. The VEN never learns that the event is completed (the reporter's TypeScript client even fails on the empty list).Cause
In
EventService.request_event,utils.order_events(self.events[ven_id])returns the very same list object when there is only one event (it short circuits forlen(events) == 1). The loop then pops the completed event fromself.events[ven_id], which is the same list asevents, so the list used for the response is emptied too. With two or more eventsorder_eventsbuilds new lists, so this was not visible.The fix
Build the response from a copy:
utils.order_events(list(self.events[ven_id])), as suggested in the issue, with a short comment explaining why.Tests
Added to
test/test_event_distribution.py:oadrResponseThe first and last tests fail without the fix and pass with it. The full test suite (without
test/conformance) passes, and flake8 is clean for the changed code.