Redesigning vote_processor::flush test to not directly modify timestamp field. The only functional change is that each vote is now its own object rather than modifying an existing one.

This commit is contained in:
clemahieu 2021-10-27 13:18:22 +01:00
commit d3ad6a05ba
No known key found for this signature in database
GPG key ID: 43708520C8DFB938

View file

@ -52,13 +52,11 @@ TEST (vote_processor, flush)
{
nano::system system (1);
auto & node (*system.nodes[0]);
auto vote (std::make_shared<nano::vote> (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 1, std::vector<nano::block_hash>{ nano::dev::genesis->hash () }));
auto channel (std::make_shared<nano::transport::channel_loopback> (node));
for (unsigned i = 0; i < 2000; ++i)
{
auto new_vote (std::make_shared<nano::vote> (*vote));
node.vote_processor.vote (new_vote, channel);
++vote->timestamp; // invalidates votes without signing again
auto vote = std::make_shared<nano::vote> (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 1 + i, std::vector<nano::block_hash>{ nano::dev::genesis->hash () });
node.vote_processor.vote (vote, channel);
}
node.vote_processor.flush ();
ASSERT_TRUE (node.vote_processor.empty ());