Skip to content
Snippets Groups Projects
Commit dd57f7b6 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix some integration tests

parent 43eefd21
No related branches found
No related tags found
No related merge requests found
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb",
"sourceFileMap": {
"${workspaceFolder}": {
"editorPath": "${workspaceFolder}",
"useForBreakpoints": "true"
}
}
}
]
}
\ No newline at end of file
......@@ -6,7 +6,6 @@ static std::shared_ptr<ftl::net::Universe> universe;
ctpl::thread_pool ftl::pool(std::thread::hardware_concurrency()*2);
/** Reset network and streams. Used by tests. */
void ftl::protocol::reset() {
universe.reset();
}
......
......@@ -165,7 +165,7 @@ void Universe::shutdown() {
UNIQUE_LOCK(net_mutex_, lk);
for (auto &s : peers_) {
s->rawClose();
if (s) s->rawClose();
}
peers_.clear();
......@@ -310,11 +310,11 @@ void Universe::_installBindings() {
void Universe::_cleanupPeers() {
auto i = peers_.begin();
while (i != peers_.end()) {
if (!(*i)->isValid() ||
(*i)->status() == NodeStatus::kReconnecting ||
(*i)->status() == NodeStatus::kDisconnected) {
auto &p = *i;
if (p && (!p->isValid() ||
p->status() == NodeStatus::kReconnecting ||
p->status() == NodeStatus::kDisconnected)) {
const auto &p = *i;
LOG(INFO) << "Removing disconnected peer: " << p->id().to_string();
_notifyDisconnect(p.get());
......@@ -328,13 +328,15 @@ void Universe::_cleanupPeers() {
}
}
i = peers_.erase(i);
//i = peers_.erase(i);
if (p->status() == NodeStatus::kReconnecting) {
reconnects_.push_back({reconnect_attempts_, 1.0f, p});
} else {
garbage_.push_back(p);
}
p.reset();
} else {
i++;
}
......
......@@ -30,7 +30,7 @@ add_test(HandleUnitTest handle_unit)
### URI ########################################################################
add_executable(net_integration
$<TARGET_OBJECTS:CatchTest>
$<TARGET_OBJECTS:CatchTestFTL>
./net_integration.cpp)
target_include_directories(net_integration PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../include")
target_link_libraries(net_integration beyond-protocol
......
......@@ -29,9 +29,9 @@ TEST_CASE("Listen and Connect", "[net]") {
auto self = ftl::createDummySelf();
self->listen(ftl::URI("tcp://localhost:0"));
auto uri = "tcp://localhost:" + std::to_string(self->getListeningURIs().front().getPort());
SECTION("valid tcp connection using ipv4") {
auto uri = "tcp://127.0.0.1:" + std::to_string(self->getListeningURIs().front().getPort());
LOG(INFO) << uri;
auto p = ftl::createNode(uri);
REQUIRE( p );
......@@ -39,19 +39,21 @@ TEST_CASE("Listen and Connect", "[net]") {
p->waitConnection();
REQUIRE( self->numberOfNodes() == 1 );
REQUIRE( ftl::getSelf()->numberOfNodes() == 1);
}
/*SECTION("valid tcp connection using hostname") {
auto p = b.connect(uri);
SECTION("valid tcp connection using hostname") {
auto uri = "tcp://localhost:" + std::to_string(self->getListeningURIs().front().getPort());
auto p = ftl::createNode(uri);
REQUIRE( p );
p->waitConnection();
REQUIRE( a.numberOfPeers() == 1 );
REQUIRE( b.numberOfPeers() == 1 );
REQUIRE( self->numberOfNodes() == 1 );
REQUIRE( ftl::getSelf()->numberOfNodes() == 1);
}
SECTION("invalid protocol") {
/*SECTION("invalid protocol") {
bool throws = false;
try {
auto p = b.connect("http://localhost:1234");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment