Skip to content

Commit 4f67ac0

Browse files
committed
Change to new context-cancelled msg contents: pikerd is canceller
1 parent 024cf8b commit 4f67ac0

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ async def _open_test_pikerd(
103103
a different port then the default to allow testing alongside
104104
a running stack.
105105
106+
Calls `.service._actor_runtime.maybe_open_pikerd()``
107+
to boot the root actor / tractor runtime.
108+
106109
'''
107110
import random
108111
from piker.service import maybe_open_pikerd

tests/test_services.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def test_runtime_boot(
3333
):
3434
'''
3535
Verify we can boot the `pikerd` service stack using the
36-
`open_test_pikerd` fixture helper and that registry address details
37-
match up.
36+
`open_test_pikerd()` fixture helper and that contact-registry
37+
address details match up.
3838
3939
'''
4040
async def main():
@@ -55,6 +55,9 @@ async def main():
5555
assert pikerd_portal.channel.raddr == daemon_addr
5656
assert pikerd_portal.channel.raddr == portal.channel.raddr
5757

58+
# no service tasks should be started
59+
assert not services.service_tasks
60+
5861
trio.run(main)
5962

6063

@@ -121,8 +124,7 @@ def test_ensure_ems_in_paper_actors(
121124
async def main():
122125

123126
# type declares
124-
book: OrderClient
125-
trades_stream: tractor.MsgStream
127+
client: OrderClient
126128
pps: dict[str, list[BrokerdPosition]]
127129
accounts: list[str]
128130
dialogs: dict[str, Status]
@@ -139,8 +141,8 @@ async def main():
139141
mode='paper',
140142
loglevel=loglevel,
141143
) as (
142-
book,
143-
trades_stream,
144+
client,
145+
_, # trades_stream: tractor.MsgStream
144146
pps,
145147
accounts,
146148
dialogs,
@@ -152,6 +154,9 @@ async def main():
152154
assert not pps
153155
assert not dialogs
154156

157+
assert not client._sent_orders
158+
assert accounts
159+
155160
pikerd_subservices = ['emsd', 'samplerd']
156161

157162
async with (
@@ -169,10 +174,13 @@ async def main():
169174
print('ALL SERVICES STARTED, terminating..')
170175
await services.cancel_service('emsd')
171176

177+
# ensure we receive a remote cancellation error caused by the
178+
# pikerd root actor since we used the `.cancel_service()` API
179+
# above B)
172180
with pytest.raises(
173181
tractor._exceptions.ContextCancelled,
174182
) as exc_info:
175183
trio.run(main)
176184

177-
cancel_msg: str = '_emsd_main()` was remotely cancelled by its caller'
178-
assert cancel_msg in exc_info.value.args[0]
185+
cancelled_msg: str = "was remotely cancelled by remote actor (\'pikerd\'"
186+
assert cancelled_msg in exc_info.value.args[0]

0 commit comments

Comments
 (0)