Skip to content

Commit

Permalink
fix request concurrency test
Browse files Browse the repository at this point in the history
  • Loading branch information
genesiscrew committed Jun 12, 2024
1 parent 46ca9be commit 0a0e4eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 9 additions & 13 deletions tests/application/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ async def test_request_concurrency(make_application, mocker):

device = app.add_initialized_device(ieee=t.EUI64(range(8)), nwk=0xAABB)

ep = device.add_endpoint(1)
ep.status = zigpy.endpoint.Status.ZDO_INIT
ep.profile_id = 260
ep.add_input_cluster(6)

# Keep track of how many requests we receive at once
in_flight_requests = 0
did_lock = False
Expand All @@ -304,7 +309,7 @@ async def callback(req):
did_lock = True

in_flight_requests += 1
assert in_flight_requests <= 10
assert in_flight_requests <= 2

await asyncio.sleep(0.1)
await zboss_server.send(c.APS.DataReq.Rsp(
Expand All @@ -317,17 +322,6 @@ async def callback(req):
TxTime=1,
DstAddrMode=req.DstAddrMode,
))
await asyncio.sleep(0.01)
await zboss_server.send(
c.APS.DataIndication.Ind(
ParamLength=21, PayloadLength=None, FrameFC=None,
SrcAddr=None, DstAddr=None, GrpAddr=None, DstEndpoint=1,
SrcEndpoint=1, ClusterId=6, ProfileId=260,
PacketCounter=None, SrcMACAddr=None, DstMACAddr=None,
LQI=None,
RSSI=None, KeySrcAndAttr=None, Payload=None, partial=True
)
)
await asyncio.sleep(0)

in_flight_requests -= 1
Expand All @@ -336,7 +330,9 @@ async def callback(req):
asyncio.create_task(callback(req))

zboss_server.reply_to(
request=c.APS.DataReq.Req(partial=True), responses=[make_response]
request=c.APS.DataReq.Req(
partial=True), responses=[make_response]

)

# We create a whole bunch at once
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def get_short_addr(self, request):
NWKAddr=t.NWK(0x1234) # Example NWK address
)

@reply_to(c.APS.DataReq.Req(partial=True))
@reply_to(c.APS.DataReq.Req(partial=True, DstEndpoint=0))
def on_zdo_request(self, req):
# kwargs = deserialize_zdo_command(req.ClusterId, req.Payload)
# handler_name = f"on_zdo_{zdo_t.ZDOCmd(req.ClusterId).name.lower()}"
Expand Down

0 comments on commit 0a0e4eb

Please sign in to comment.