Fix vote_processor.codes
test
This commit is contained in:
parent
632b73e3e3
commit
a770ea15fb
3 changed files with 13 additions and 1 deletions
|
@ -25,9 +25,12 @@ TEST (vote_processor, codes)
|
|||
// Hint of pre-validation
|
||||
ASSERT_NE (nano::vote_code::invalid, node.vote_processor.vote_blocking (vote_invalid, channel, true));
|
||||
|
||||
// No ongoing election
|
||||
// No ongoing election (vote goes to vote cache)
|
||||
ASSERT_EQ (nano::vote_code::indeterminate, node.vote_processor.vote_blocking (vote, channel));
|
||||
|
||||
// Clear vote cache before starting election
|
||||
node.vote_cache.clear ();
|
||||
|
||||
// First vote from an account for an ongoing election
|
||||
node.start_election (blocks[0]);
|
||||
std::shared_ptr<nano::election> election;
|
||||
|
|
|
@ -193,6 +193,12 @@ bool nano::vote_cache::erase (const nano::block_hash & hash)
|
|||
return result;
|
||||
}
|
||||
|
||||
void nano::vote_cache::clear ()
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock{ mutex };
|
||||
cache.clear ();
|
||||
}
|
||||
|
||||
std::vector<nano::vote_cache::top_entry> nano::vote_cache::top (const nano::uint128_t & min_tally)
|
||||
{
|
||||
stats.inc (nano::stat::type::vote_cache, nano::stat::detail::top);
|
||||
|
|
|
@ -97,15 +97,18 @@ public:
|
|||
* Adds a new vote to cache
|
||||
*/
|
||||
void vote (nano::block_hash const & hash, std::shared_ptr<nano::vote> vote);
|
||||
|
||||
/**
|
||||
* Tries to find an entry associated with block hash
|
||||
*/
|
||||
std::optional<entry> find (nano::block_hash const & hash) const;
|
||||
|
||||
/**
|
||||
* Removes an entry associated with block hash, does nothing if entry does not exist
|
||||
* @return true if hash existed and was erased, false otherwise
|
||||
*/
|
||||
bool erase (nano::block_hash const & hash);
|
||||
void clear ();
|
||||
|
||||
std::size_t size () const;
|
||||
bool empty () const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue