Skip to content

Commit

Permalink
follow-up for fabric-scoped event
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Aug 19, 2022
1 parent 3acafb1 commit f498e3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/EventLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventNumber & aE
eventOptions.mPriority = aEventData.GetPriorityLevel();
eventOptions.mFabricIndex = aEventData.GetFabricIndex();
// this skips logging the event if it's fabric-scoped but no fabric association exists yet.
VerifyOrReturnError(eventOptions.mFabricIndex != kUndefinedFabricIndex, CHIP_NO_ERROR);
VerifyOrReturnError(eventOptions.mFabricIndex != kUndefinedFabricIndex, CHIP_ERROR_INVALID_FABRIC_INDEX);

//
// Unlike attributes which have a different 'EncodeForRead' for fabric-scoped structs,
Expand Down
14 changes: 10 additions & 4 deletions src/controller/python/test/test_scripts/cluster_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ async def _TriggerEvent(cls, devCtrl):
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestEventRequest())
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestEventRequest())
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestEventRequest())
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=0))
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=1))

@classmethod
async def _RetryForContent(cls, request, until, retryCount=10, intervalSeconds=1):
Expand All @@ -335,11 +333,19 @@ async def TriggerAndWaitForEvents(cls, devCtrl, req):
@base.test_case
async def TestGenerateUndefinedFabricScopedEventRequests(cls, devCtrl):
logger.info("Running TestGenerateUndefinedFabricScopedEventRequests")
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=0))
try:
res = await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=Clusters.TestCluster.Commands.TestEmitTestFabricScopedEventRequest(arg1=0))
raise ValueError(f"Unexpected Failure")
except chip.interaction_model.InteractionModelError as ex:
logger.info(f"Recevied {ex} from server.")
res = await devCtrl.ReadEvent(nodeid=NODE_ID, events=[
(1, Clusters.TestCluster.Events.TestEvent, 0),
(1, Clusters.TestCluster.Events.TestFabricScopedEvent, 0),
])
logger.info(f"return result is {res}")
if len(res) != 0:
raise AssertionError("failure: not expect to receive fabric-scoped event when fabric is undefined")
else:
logger.info("TestGenerateUndefinedFabricScopedEventRequests: Success")

@classmethod
@base.test_case
Expand Down

0 comments on commit f498e3d

Please sign in to comment.