From 0ab8d26aeec9cab8c6a314f6d653c627274e93a7 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Wed, 5 Aug 2015 16:44:32 +0200 Subject: [PATCH] peer test updated --- test/libp2p/peer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/libp2p/peer.cpp b/test/libp2p/peer.cpp index fa04be5fd..43308b450 100644 --- a/test/libp2p/peer.cpp +++ b/test/libp2p/peer.cpp @@ -152,8 +152,9 @@ BOOST_AUTO_TEST_CASE(requirePeer) if (test::Options::get().nonetwork) return; - VerbosityHolder reduceVerbosity(10); + VerbosityHolder temporaryLevel(10); + unsigned const step = 10; const char* const localhost = "127.0.0.1"; NetworkPreferences prefs1(localhost, 30323, false); NetworkPreferences prefs2(localhost, 30324, false); @@ -166,7 +167,8 @@ BOOST_AUTO_TEST_CASE(requirePeer) auto node2 = host2.id(); host1.requirePeer(node2, NodeIPEndpoint(bi::address::from_string(localhost), prefs2.listenPort, prefs2.listenPort)); - this_thread::sleep_for(chrono::seconds(3)); + for (unsigned i = 0; i < 3000 && (!host1.peerCount() || !host2.peerCount()); i += step) + this_thread::sleep_for(chrono::milliseconds(step)); auto host1peerCount = host1.peerCount(); auto host2peerCount = host2.peerCount(); @@ -190,7 +192,8 @@ BOOST_AUTO_TEST_CASE(requirePeer) host1.relinquishPeer(node2); - this_thread::sleep_for(chrono::seconds(1)); + for (unsigned i = 0; i < 2000 && (host1.peerCount() || host2.peerCount()); i += step) + this_thread::sleep_for(chrono::milliseconds(step)); host1peerCount = host1.peerCount(); host2peerCount = host2.peerCount();