-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Keep io context running when stopping test system #4525
Keep io context running when stopping test system #4525
Conversation
18aa5ae
to
2fd368a
Compare
6479c8e
to
8eb54ba
Compare
std::shared_ptr<nano::node> nano::test::system::make_disconnected_node (std::optional<nano::node_config> opt_node_config, nano::node_flags flags) | ||
{ | ||
nano::node_config node_config = opt_node_config.has_value () ? *opt_node_config : default_config (); | ||
auto node = std::make_shared<nano::node> (io_ctx, nano::unique_path (), node_config, work, flags); | ||
if (node->init_error ()) | ||
for (auto i : initialization_blocks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make_disconnected_node() is typically used when someone wants a node without any initialisation and no network connections. the name I gave it isn't ideal, in hindsight, as it implied the node is only disconnected. It replaced code that was constructing nano::node objects without the use of system resources.
So, I think it would be best to not any additional initialisation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out. I'll be revisiting the way nodes are added to the system with subsequent io context rework.
Ideally, asio io context would be running through the test lifetime with each component being responsible for properly canceling and joining its async operations. Getting to this point is going to take a bit more work, but this PR is a step towards this goal. It keeps io loop running when stopping nodes, which in turn allows async handlers to complete. Getting it to work required fixing a few lifetime issues and that's also a part of this PR.
Getting this merged will unblock #4523