aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_msgnet_c.c7
-rw-r--r--test/test_p2p.cpp9
-rw-r--r--test/test_p2p_stress.cpp10
3 files changed, 21 insertions, 5 deletions
diff --git a/test/test_msgnet_c.c b/test/test_msgnet_c.c
index b2fb35a..c2fb492 100644
--- a/test/test_msgnet_c.c
+++ b/test/test_msgnet_c.c
@@ -139,6 +139,13 @@ void conn_handler(const msgnetwork_conn_t *conn, bool connected, void *userdata)
}
}
+void error_handler(const SalticidaeCError *err, bool fatal, void *userdata) {
+ MyNet *n = (MyNet *)userdata;
+ printf("[%s] Captured %s error during an async call: %s\n",
+ n->name, fatal ? "fatal" : "recoverable",
+ salticidae_strerror(err->code));
+}
+
MyNet gen_mynet(const eventcontext_t *ec,
const char *name) {
MyNet res;
diff --git a/test/test_p2p.cpp b/test/test_p2p.cpp
index 6d311a6..14304eb 100644
--- a/test/test_p2p.cpp
+++ b/test/test_p2p.cpp
@@ -79,8 +79,13 @@ struct Net {
net->reg_handler([this](const MsgText &msg, const PeerNetwork::conn_t &) {
fprintf(stdout, "net %lu: peer %lu says %s\n", this->id, msg.id, msg.text.c_str());
});
- net->reg_error_handler([this](const std::exception &err, bool fatal) {
- fprintf(stdout, "net %lu: captured %s error during an async call: %s\n", this->id, fatal ? "fatal" : "recoverable", err.what());
+ net->reg_error_handler([this](const std::exception_ptr _err, bool fatal) {
+ try {
+ std::rethrow_exception(_err);
+ } catch (const std::exception &err) {
+ fprintf(stdout, "net %lu: captured %s error during an async call: %s\n",
+ this->id, fatal ? "fatal" : "recoverable", err.what());
+ }
});
net->reg_unknown_peer_handler([this](const NetAddr &addr) {
fprintf(stdout, "net %lu: unknown peer attempts to connnect %s\n", this->id, std::string(addr).c_str());
diff --git a/test/test_p2p_stress.cpp b/test/test_p2p_stress.cpp
index 3a71660..92e5bb4 100644
--- a/test/test_p2p_stress.cpp
+++ b/test/test_p2p_stress.cpp
@@ -114,9 +114,13 @@ void install_proto(AppContext &app, const size_t &seg_buff_size) {
}
}
});
- net.reg_error_handler([ec](const std::exception &err, bool fatal) {
- SALTICIDAE_LOG_WARN("main thread captured %s error: %s",
- fatal ? "fatal" : "recoverable", err.what());
+ net.reg_error_handler([ec](const std::exception_ptr _err, bool fatal) {
+ try {
+ std::rethrow_exception(_err);
+ } catch (const std::exception & err) {
+ SALTICIDAE_LOG_WARN("main thread captured %s error: %s",
+ fatal ? "fatal" : "recoverable", err.what());
+ }
});
net.reg_handler([&](MsgRand &&msg, const MyNet::conn_t &conn) {
uint256_t hash = salticidae::get_hash(msg.bytes);