mirror of
https://github.com/logos-co/logos-libp2p-module.git
synced 2026-08-31 01:41:12 +00:00
ci(tutorials): add smoke test for code (#85)
This commit is contained in:
@@ -65,14 +65,18 @@ int main()
|
||||
|
||||
/// Verify that the node is actually listening on the configured port:
|
||||
auto info = node.peerInfo();
|
||||
if (info.success) {
|
||||
printf("\nNode is live!\n");
|
||||
printf(" Peer ID: %s\n",
|
||||
info.value["peerId"].get<std::string>().c_str());
|
||||
for (const auto& addr : info.value["addrs"]) {
|
||||
printf(" Listening on: %s\n",
|
||||
addr.get<std::string>().c_str());
|
||||
}
|
||||
if (!info.success) {
|
||||
fprintf(stderr, "Failed to get node info: %s\n",
|
||||
info.error.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\nNode is live!\n");
|
||||
printf(" Peer ID: %s\n",
|
||||
info.value["peerId"].get<std::string>().c_str());
|
||||
for (const auto& addr : info.value["addrs"]) {
|
||||
printf(" Listening on: %s\n",
|
||||
addr.get<std::string>().c_str());
|
||||
}
|
||||
|
||||
node.stop();
|
||||
@@ -114,14 +118,18 @@ int main()
|
||||
}
|
||||
|
||||
auto info2 = nodeFromJson.peerInfo();
|
||||
if (info2.success) {
|
||||
printf("\nJSON-configured node is live!\n");
|
||||
printf(" Peer ID: %s\n",
|
||||
info2.value["peerId"].get<std::string>().c_str());
|
||||
for (const auto& addr : info2.value["addrs"]) {
|
||||
printf(" Listening on: %s\n",
|
||||
addr.get<std::string>().c_str());
|
||||
}
|
||||
if (!info2.success) {
|
||||
fprintf(stderr, "Failed to get JSON-configured node info: %s\n",
|
||||
info2.error.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("\nJSON-configured node is live!\n");
|
||||
printf(" Peer ID: %s\n",
|
||||
info2.value["peerId"].get<std::string>().c_str());
|
||||
for (const auto& addr : info2.value["addrs"]) {
|
||||
printf(" Listening on: %s\n",
|
||||
addr.get<std::string>().c_str());
|
||||
}
|
||||
|
||||
nodeFromJson.stop();
|
||||
@@ -157,4 +165,4 @@ int main()
|
||||
///
|
||||
/// ```bash
|
||||
/// ./build/tutorial/tutorial_2_custom_config
|
||||
/// ```
|
||||
/// ```
|
||||
|
||||
Reference in New Issue
Block a user