Skip to content

Commit

Permalink
disable p2p in unit tests
Browse files Browse the repository at this point in the history
The change replaces previous measure against unit tests "talking with outside world" as that
way would sometimes cause problems with debugging (especially concurrent debugging of two
versions was not possible).
  • Loading branch information
ABW committed Sep 19, 2023
1 parent dc07265 commit d745a23
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions libraries/plugins/chain/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,4 +1351,9 @@ bool chain_plugin::is_p2p_enabled() const
return my->is_p2p_enabled;
}

void chain_plugin::disable_p2p() const
{
my->is_p2p_enabled = false;
}

} } } // namespace hive::plugis::chain::chain_apis
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class chain_plugin : public plugin< chain_plugin >
synchronization_type on_sync;

bool is_p2p_enabled() const;
void disable_p2p() const;

private:
std::unique_ptr< detail::chain_plugin_impl, detail::chain_plugin_impl_deleter > my;
Expand Down
2 changes: 1 addition & 1 deletion libraries/plugins/witness/witness_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void witness_plugin::plugin_startup()

if( !my->_is_p2p_enabled )
{
ilog("Witness plugin is not enabled, beause P2P plugin is disabled...");
ilog("Witness plugin is not enabled, because P2P plugin is disabled...");
return;
}

Expand Down
10 changes: 4 additions & 6 deletions tests/unit/db_fixture/hived_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ void hived_fixture::postponed_init_impl( const config_arg_override_t& config_arg
// Register every plugin existing in repository as hived does.
hive::plugins::register_plugins();

// We don't want p2p plugin connections at all.
config_arg_override_t default_overrides = {
config_line_t( { "p2p-endpoint", { "127.0.0.1:2345" } } ),
config_line_t( { "p2p-seed-node",{ " " } } )
};
config_arg_override_t default_overrides = {};

if( not config_arg_overrides.empty() )
std::copy_if( config_arg_overrides.begin(),
Expand Down Expand Up @@ -113,7 +109,9 @@ void hived_fixture::postponed_init_impl( const config_arg_override_t& config_arg
BOOST_REQUIRE( db_plugin );
db_plugin->logging = false;

db = &app.get_plugin< hive::plugins::chain::chain_plugin >().db();
auto& chain = app.get_plugin< hive::plugins::chain::chain_plugin >();
chain.disable_p2p(); // We don't want p2p plugin connections at all.
db = &chain.db();
BOOST_REQUIRE( db );
db->_log_hardforks = false;

Expand Down

0 comments on commit d745a23

Please sign in to comment.