Skip to content

Commit

Permalink
Avoid timing issue in app_test
Browse files Browse the repository at this point in the history
  • Loading branch information
pmconrad committed Nov 21, 2019
1 parent 5f8de6b commit a96aa5a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,14 @@ BOOST_AUTO_TEST_CASE( two_node_network )
cfg2.emplace("seed-nodes", boost::program_options::variable_value(string("[]"), false));
app2.initialize(app2_dir.path(), cfg2);

BOOST_TEST_MESSAGE( "Starting app2 and waiting 500 ms" );
BOOST_TEST_MESSAGE( "Starting app2 and waiting for connection" );
app2.startup();
fc::usleep(fc::milliseconds(500));

const auto start = fc::time_point::now();
do
{
fc::usleep(fc::milliseconds(200));
} while( app1.p2p_node()->get_connection_count() < 1 && fc::time_point::now() < start + fc::seconds(5) );

BOOST_REQUIRE_EQUAL(app1.p2p_node()->get_connection_count(), 1u);
BOOST_CHECK_EQUAL(std::string(app1.p2p_node()->get_connected_peers().front().host.get_address()), "127.0.0.1");
Expand Down

0 comments on commit a96aa5a

Please sign in to comment.