Skip to content

Commit b46903e

Browse files
Waiting indefinitely for node to join network even for tests
1 parent 53a24f4 commit b46903e

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed

include/maidsafe/session_handler.h

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,23 +172,28 @@ void SessionHandler<Session>::Login(authentication::UserCredentials&& user_crede
172172
Identity session_location{ detail::GetSessionLocation(*user_credentials.keyword,
173173
*user_credentials.pin) };
174174
LOG(kVerbose) << "Session location: " << HexSubstr(session_location);
175-
auto versions_future =
176-
session_getter_->data_getter().GetVersions(MutableData::Name(session_location));
177-
LOG(kVerbose) << "Waiting for versions_future";
178-
auto versions(versions_future.get());
179-
LOG(kVerbose) << "GetVersions from session location succeeded";
180-
assert(versions.size() == 1U);
181-
// TODO(Fraser#5#): 2014-04-17 - Get more than just the latest version - possibly just for the
182-
// case where the latest one fails. Or just throw, but add 'int version_number' to this
183-
// function's signature where 0 == most recent, 1 == second newest, etc.
184-
auto encrypted_serialised_session_future(session_getter_->data_getter().Get(versions.at(0).id));
185-
auto encrypted_serialised_session(encrypted_serialised_session_future.get());
186-
LOG(kVerbose) << "Get encrypted_serialised_session succeeded";
187-
session_ = maidsafe::make_unique<Session>(
188-
detail::DecryptSession<Session>(user_credentials, encrypted_serialised_session));
189-
current_session_version_ = versions.at(0);
190-
user_credentials_ = std::move(user_credentials);
191-
session_getter_.reset();
175+
try {
176+
auto versions_future =
177+
session_getter_->data_getter().GetVersions(MutableData::Name(session_location));
178+
LOG(kVerbose) << "Waiting for versions_future";
179+
auto versions(versions_future.get());
180+
LOG(kVerbose) << "GetVersions from session location succeeded";
181+
assert(versions.size() == 1U);
182+
// TODO(Fraser#5#): 2014-04-17 - Get more than just the latest version - possibly just for the
183+
// case where the latest one fails. Or just throw, but add 'int version_number' to this
184+
// function's signature where 0 == most recent, 1 == second newest, etc.
185+
auto encrypted_serialised_session_future(session_getter_->data_getter().Get(versions.at(0).id));
186+
auto encrypted_serialised_session(encrypted_serialised_session_future.get());
187+
LOG(kVerbose) << "Get encrypted_serialised_session succeeded";
188+
session_ = maidsafe::make_unique<Session>(
189+
detail::DecryptSession<Session>(user_credentials, encrypted_serialised_session));
190+
current_session_version_ = versions.at(0);
191+
user_credentials_ = std::move(user_credentials);
192+
session_getter_.reset();
193+
} catch (const std::exception& e) {
194+
LOG(kError) << "Failed to Login. Error: " << boost::diagnostic_information(e);
195+
throw;
196+
}
192197
}
193198

194199
template <typename Session>

src/maidsafe/detail/client_impl.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,7 @@ void ClientImpl::InitRouting(const BootstrapInfo& bootstrap_info) {
145145
// FIXME BEFORE_RELEASE discuss this
146146
// This should behave differently. In case of new maid account, it should timeout
147147
// For existing clients, should we try infinitly ?
148-
149-
#ifdef TESTING
150-
if (!network_health_condition_variable_.wait_for(lock, std::chrono::minutes(5), [this] {
151-
return network_health_ == 100;
152-
}))
153-
BOOST_THROW_EXCEPTION(MakeError(VaultErrors::failed_to_join_network));
154-
#else
155148
network_health_condition_variable_.wait(lock, [this] { return network_health_ >= 100; });
156-
#endif
157149
}
158150

159151
routing::Functors ClientImpl::InitialiseRoutingCallbacks() {

src/maidsafe/detail/session_getter.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,7 @@ void SessionGetter::InitRouting(const BootstrapInfo& bootstrap_info) {
4646
routing_.Join(functors, peer_endpoints);
4747
// FIXME BEFORE_RELEASE discuss this
4848
std::unique_lock<std::mutex> lock{ network_health_mutex_ };
49-
#ifdef TESTING
50-
if (!network_health_condition_variable_.wait_for(lock, std::chrono::minutes(5), [this] {
51-
return network_health_ == 100; // FIXME need parameter here ?
52-
}))
53-
BOOST_THROW_EXCEPTION(MakeError(VaultErrors::failed_to_join_network));
54-
#else
5549
network_health_condition_variable_.wait(lock, [this] { return network_health_ == 100; });
56-
#endif
5750
}
5851

5952
routing::Functors SessionGetter::InitialiseRoutingCallbacks() {

0 commit comments

Comments
 (0)