Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for test election.quorum_minimum_update_weight_before_quorum_checks #3932

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion nano/core_test/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ TEST (election, quorum_minimum_confirm_fail)

namespace nano
{
// FIXME: this test fails on rare occasions. It needs a review.
TEST (election, quorum_minimum_update_weight_before_quorum_checks)
{
nano::test::system system{};
Expand Down Expand Up @@ -243,7 +244,7 @@ TEST (election, quorum_minimum_update_weight_before_quorum_checks)
ASSERT_NE (channel, nullptr);

auto const vote2 = std::make_shared<nano::vote> (key1.pub, key1.prv, nano::vote::timestamp_max, nano::vote::duration_max, std::vector<nano::block_hash>{ send1->hash () });
ASSERT_TIMELY (10s, !node1.rep_crawler.response (channel, vote2));
ASSERT_FALSE (node1.rep_crawler.response (channel, vote2, true));

ASSERT_FALSE (election->confirmed ());
{
Expand Down
4 changes: 2 additions & 2 deletions nano/node/repcrawler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ bool nano::rep_crawler::is_pr (nano::transport::channel const & channel_a) const
return result;
}

bool nano::rep_crawler::response (std::shared_ptr<nano::transport::channel> const & channel_a, std::shared_ptr<nano::vote> const & vote_a)
bool nano::rep_crawler::response (std::shared_ptr<nano::transport::channel> const & channel_a, std::shared_ptr<nano::vote> const & vote_a, bool force)
{
bool error = true;
nano::lock_guard<nano::mutex> lock (active_mutex);
for (auto i = vote_a->hashes.begin (), n = vote_a->hashes.end (); i != n; ++i)
{
if (active.count (*i) != 0)
if (force || active.count (*i) != 0)
{
responses.emplace_back (channel_a, vote_a);
error = false;
Expand Down
5 changes: 3 additions & 2 deletions nano/node/repcrawler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ class rep_crawler final
/**
* Called when a non-replay vote on a block previously sent by query() is received. This indicates
* with high probability that the endpoint is a representative node.
* @return false if the vote corresponded to any active hash.
* The force flag can be set to skip the active check in unit testing when we want to force a vote in the rep crawler.
* @return false if any vote passed the checks and was added to the response queue of the rep crawler
*/
bool response (std::shared_ptr<nano::transport::channel> const &, std::shared_ptr<nano::vote> const &);
bool response (std::shared_ptr<nano::transport::channel> const &, std::shared_ptr<nano::vote> const &, bool force = false);

/** Get total available weight from representatives */
nano::uint128_t total_weight () const;
Expand Down