diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-10-21 08:52:53 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-10-21 08:52:55 +0200 |
commit | e81aea0fc96a2eb44e09d3aa0aad1e7d11878cae (patch) | |
tree | 62006080a5747622e83df76eefb7eca230f40a6d /tests | |
parent | 54254462e432dcc6ef2bb306a9ee773d21314d19 (diff) |
Fix concurrent connection to the same address
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/main.cpp b/tests/main.cpp index d6c37e2..e262e02 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -11,6 +11,7 @@ const int PORT = 35231; int main() { const sibs::PubsubKey key("abcdefghijklmnopqrstuvxyz0123456789", 35); + const sibs::PubsubKey key2("zbcdefghcjklmn3pqrs5uvx2z0123F56789", 35); sibs::BootstrapNode boostrapNode(sibs::Ipv4(nullptr, PORT)); sibs::BootstrapConnection connection1(sibs::Ipv4("127.0.0.1", PORT)); @@ -36,9 +37,26 @@ int main() gotAsdf2 = true; return true; }); + + bool gotListen = false; + connection1.listen(key2, [&gotListen](const sibs::DirectConnectionPeer *peer, const void *data, const sibs::usize size) + { + if(size == 14 && strncmp((const char*)data, "secondListener", 14) == 0) + gotListen = true; + return true; + }); + + bool gotListen2 = false; + connection2.listen(key2, [&gotListen2](const sibs::DirectConnectionPeer *peer, const void *data, const sibs::usize size) + { + if(size == 14 && strncmp((const char*)data, "secondListener", 14) == 0) + gotListen2 = true; + return true; + }); connection1.put(key, "hello", 5); connection2.put(key, "asdf", 4); + connection1.put(key2, "secondListener", 14); std::this_thread::sleep_for(std::chrono::seconds(6)); REQUIRE(gotData1); @@ -46,5 +64,8 @@ int main() REQUIRE(gotData2); REQUIRE(gotAsdf2); + REQUIRE(gotListen); + REQUIRE(gotListen2); + return 0; } |