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 vote rebroadcasting #1141

Merged
merged 2 commits into from Sep 3, 2018
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
40 changes: 40 additions & 0 deletions rai/core_test/node.cpp
Expand Up @@ -1611,3 +1611,43 @@ TEST (node, confirm_quorum)
}
ASSERT_EQ (0, system.nodes[0]->balance (rai::test_genesis_key.pub));
}

TEST (node, vote_republish)
{
rai::system system (24000, 2);
rai::keypair key2;
system.wallet (1)->insert_adhoc (key2.prv);
rai::genesis genesis;
rai::send_block send1 (genesis.hash (), key2.pub, std::numeric_limits<rai::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ()));
rai::send_block send2 (genesis.hash (), key2.pub, std::numeric_limits<rai::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number () * 2, rai::test_genesis_key.prv, rai::test_genesis_key.pub, system.work.generate (genesis.hash ()));
system.nodes[0]->process_active (std::unique_ptr<rai::block> (new rai::send_block (send1)));
system.deadline_set (5s);
while (!system.nodes[1]->block (send1.hash ()))
{
ASSERT_NO_ERROR (system.poll ());
}
system.nodes[0]->active.publish (std::unique_ptr<rai::block> (new rai::send_block (send2)));
auto vote (std::make_shared<rai::vote> (rai::test_genesis_key.pub, rai::test_genesis_key.prv, 0, std::unique_ptr<rai::block> (new rai::send_block (send2))));
ASSERT_TRUE (system.nodes[0]->active.active (send1));
ASSERT_TRUE (system.nodes[1]->active.active (send1));
system.nodes[0]->vote_processor.vote (vote, system.nodes[0]->network.endpoint ());
while (!system.nodes[0]->block (send2.hash ()))
{
ASSERT_NO_ERROR (system.poll ());
}
while (!system.nodes[1]->block (send2.hash ()))
{
ASSERT_NO_ERROR (system.poll ());
}
ASSERT_FALSE (system.nodes[0]->block (send1.hash ()));
ASSERT_FALSE (system.nodes[1]->block (send1.hash ()));
system.deadline_set (5s);
while (system.nodes[1]->balance (key2.pub) != system.nodes[0]->config.receive_minimum.number () * 2)
{
ASSERT_NO_ERROR (system.poll ());
}
while (system.nodes[0]->balance (key2.pub) != system.nodes[0]->config.receive_minimum.number () * 2)
{
ASSERT_NO_ERROR (system.poll ());
}
}
1 change: 0 additions & 1 deletion rai/node/node.cpp
Expand Up @@ -3652,7 +3652,6 @@ rai::election_vote_result rai::election::vote (rai::account rep, uint64_t sequen
{
cooldown = 1;
}
auto should_process (false);
auto last_vote_it (last_votes.find (rep));
if (last_vote_it == last_votes.end ())
{
Expand Down