Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't crash on no public_did, add test #637

Merged
merged 1 commit into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aries_cloudagent/core/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ async def start(self) -> None:

# Get public did
wallet: BaseWallet = await context.inject(BaseWallet)
public_did = (await wallet.get_public_did()).did
public_did = await wallet.get_public_did()

# Show some details about the configuration to the user
LoggingConfigurator.print_banner(
default_label,
self.inbound_transport_manager.registered_transports,
self.outbound_transport_manager.registered_transports,
public_did,
public_did.did if public_did else None,
self.admin_server,
)

Expand Down
33 changes: 33 additions & 0 deletions aries_cloudagent/core/tests/test_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,39 @@ async def test_startup(self):
mock_inbound_mgr.return_value.stop.assert_awaited_once_with()
mock_outbound_mgr.return_value.stop.assert_awaited_once_with()

async def test_startup_no_public_did(self):
builder: ContextBuilder = StubContextBuilder(self.test_settings)
conductor = test_module.Conductor(builder)

with async_mock.patch.object(
test_module, "InboundTransportManager", autospec=True
) as mock_inbound_mgr, async_mock.patch.object(
test_module, "OutboundTransportManager", autospec=True
) as mock_outbound_mgr, async_mock.patch.object(
test_module, "LoggingConfigurator", autospec=True
) as mock_logger:

await conductor.setup()

mock_inbound_mgr.return_value.setup.assert_awaited_once()
mock_outbound_mgr.return_value.setup.assert_awaited_once()

mock_inbound_mgr.return_value.registered_transports = {}
mock_outbound_mgr.return_value.registered_transports = {}

# Doesn't raise
await conductor.start()

mock_inbound_mgr.return_value.start.assert_awaited_once_with()
mock_outbound_mgr.return_value.start.assert_awaited_once_with()

mock_logger.print_banner.assert_called_once()

await conductor.stop()

mock_inbound_mgr.return_value.stop.assert_awaited_once_with()
mock_outbound_mgr.return_value.stop.assert_awaited_once_with()

async def test_stats(self):
builder: ContextBuilder = StubContextBuilder(self.test_settings)
conductor = test_module.Conductor(builder)
Expand Down