aboutsummaryrefslogtreecommitdiff
path: root/test/test_network.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_network.cpp')
-rw-r--r--test/test_network.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/test/test_network.cpp b/test/test_network.cpp
index d93d0ff..d52b6c2 100644
--- a/test/test_network.cpp
+++ b/test/test_network.cpp
@@ -132,7 +132,14 @@ salticidae::EventContext ec;
NetAddr alice_addr("127.0.0.1:12345");
NetAddr bob_addr("127.0.0.1:12346");
+void signal_handler(int) {
+ throw salticidae::SalticidaeError("got termination signal");
+}
+
int main() {
+ signal(SIGTERM, signal_handler);
+ signal(SIGINT, signal_handler);
+
/* test two nodes */
MyNet alice(ec, "Alice", bob_addr);
MyNet bob(ec, "Bob", alice_addr);
@@ -141,16 +148,18 @@ int main() {
alice.reg_handler(on_receive_ack);
bob.reg_handler(on_receive_ack);
- alice.start();
- bob.start();
+ try {
+ alice.start();
+ bob.start();
- alice.listen(alice_addr);
- bob.listen(bob_addr);
+ alice.listen(alice_addr);
+ bob.listen(bob_addr);
- /* first attempt */
- alice.connect(bob_addr);
- bob.connect(alice_addr);
+ /* first attempt */
+ alice.connect(bob_addr);
+ bob.connect(alice_addr);
- ec.dispatch();
+ ec.dispatch();
+ } catch (salticidae::SalticidaeError &e) {}
return 0;
}