Skip to content

Commit

Permalink
Merge pull request #2377 from bitshares/fix-app-test
Browse files Browse the repository at this point in the history
Return peer sync status in get_connected_peers()
  • Loading branch information
abitmore authored Mar 10, 2021
2 parents 099ff23 + ecc8a0d commit 343fcdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libraries/net/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4653,6 +4653,9 @@ namespace graphene { namespace net { namespace detail {
peer_details["current_head_block_number"] = _delegate->get_block_number(peer->last_block_delegate_has_seen);
peer_details["current_head_block_time"] = peer->last_block_time_delegate_has_seen;

peer_details["peer_needs_sync_items_from_us"] = peer->peer_needs_sync_items_from_us;
peer_details["we_need_sync_items_from_peer"] = peer->we_need_sync_items_from_peer;

this_peer_status.info = peer_details;
statuses.push_back(this_peer_status);
}
Expand Down
14 changes: 13 additions & 1 deletion tests/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,19 @@ BOOST_AUTO_TEST_CASE( two_node_network )
BOOST_TEST_MESSAGE( "Starting app2 and waiting for connection" );
app2.startup();

fc::wait_for( node_startup_wait_time, [&app1] () { return app1.p2p_node()->get_connection_count() > 0; } );
fc::wait_for( node_startup_wait_time, [&app1] () {
if( app1.p2p_node()->get_connection_count() > 0 )
{
auto peers = app1.p2p_node()->get_connected_peers();
BOOST_REQUIRE_EQUAL( peers.size(), 1u );
const auto& peer_info = peers.front().info;
auto itr = peer_info.find( "peer_needs_sync_items_from_us" );
if( itr == peer_info.end() )
return false;
return !itr->value().as<bool>(1);
}
return false;
});

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 343fcdf

Please sign in to comment.