More cleanup
This commit is contained in:
parent
e519bbb740
commit
0b0c0adbd8
6 changed files with 28 additions and 8 deletions
|
|
@ -260,11 +260,9 @@ TEST (election, quorum_minimum_update_weight_before_quorum_checks)
|
|||
node1.rep_crawler.force_process (vote2, channel);
|
||||
|
||||
ASSERT_FALSE (election->confirmed ());
|
||||
{
|
||||
nano::lock_guard<nano::mutex> guard (node1.online_reps.mutex);
|
||||
|
||||
// Modify online_m for online_reps to more than is available, this checks that voting below updates it to current online reps.
|
||||
node1.online_reps.online_m = node_config.online_weight_minimum.number () + 20;
|
||||
}
|
||||
node1.online_reps.force_online_weight (node_config.online_weight_minimum.number () + 20);
|
||||
ASSERT_EQ (nano::vote_code::vote, node1.vote_router.vote (vote2).at (send1->hash ()));
|
||||
ASSERT_TIMELY (5s, election->confirmed ());
|
||||
ASSERT_NE (nullptr, node1.block (send1->hash ()));
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ void force_nano_dev_network ()
|
|||
nano::network_constants::set_active_network (nano::networks::nano_dev_network);
|
||||
}
|
||||
|
||||
bool is_dev_run ()
|
||||
{
|
||||
return nano::network_constants::get_active_network () == nano::networks::nano_dev_network;
|
||||
}
|
||||
|
||||
bool running_within_valgrind ()
|
||||
{
|
||||
return (RUNNING_ON_VALGRIND > 0);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ bool slow_instrumentation ();
|
|||
|
||||
/** Set the active network to the dev network */
|
||||
void force_nano_dev_network ();
|
||||
|
||||
/** Checks that we are running in test mode */
|
||||
bool is_dev_run ();
|
||||
}
|
||||
|
||||
namespace nano
|
||||
|
|
|
|||
|
|
@ -205,6 +205,11 @@ public:
|
|||
active_network = network_a;
|
||||
}
|
||||
|
||||
static nano::networks get_active_network ()
|
||||
{
|
||||
return active_network;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally called on startup to override the global active network.
|
||||
* If not called, the compile-time option will be used.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <nano/lib/config.hpp>
|
||||
#include <nano/node/nodeconfig.hpp>
|
||||
#include <nano/node/online_reps.hpp>
|
||||
#include <nano/secure/ledger.hpp>
|
||||
|
|
@ -117,6 +118,13 @@ void nano::online_reps::clear ()
|
|||
online_m = 0;
|
||||
}
|
||||
|
||||
void nano::online_reps::force_online_weight (nano::uint128_t const & online_weight)
|
||||
{
|
||||
release_assert (nano::is_dev_run ());
|
||||
nano::lock_guard<nano::mutex> lock{ mutex };
|
||||
online_m = online_weight;
|
||||
}
|
||||
|
||||
nano::container_info nano::online_reps::container_info () const
|
||||
{
|
||||
nano::lock_guard<nano::mutex> guard{ mutex };
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ private:
|
|||
|
||||
mutable nano::mutex mutex;
|
||||
|
||||
friend class election_quorum_minimum_update_weight_before_quorum_checks_Test;
|
||||
public: // Only for tests
|
||||
void force_online_weight (nano::uint128_t const & online_weight);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue