Update conflicts.adjusted_difficulty test (#1932)

* Update conflicts.adjusted_difficulty test

* Add could_fit_delay for removing active transactions (1 for live/beta network, 10 for test network)
This commit is contained in:
Sergey Kroshnin 2019-04-26 13:23:45 +03:00 committed by GitHub
commit cd1c90d02e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -244,7 +244,11 @@ TEST (conflicts, adjusted_difficulty)
auto change1 (std::make_shared<nano::state_block> (key3.pub, open2->hash (), nano::test_genesis_key.pub, nano::xrb_ratio, 0, key3.prv, key3.pub, system.work.generate (open2->hash ())));
node1.process_active (change1);
node1.block_processor.flush ();
ASSERT_EQ (11, node1.active.size ());
system.deadline_set (3s);
while (node1.active.size () != 11)
{
ASSERT_NO_ERROR (system.poll ());
}
std::unordered_map<nano::block_hash, uint64_t> adjusted_difficulties;
{
std::lock_guard<std::mutex> guard (node1.active.mutex);
@ -276,7 +280,11 @@ TEST (conflicts, adjusted_difficulty)
ASSERT_GT (difficulty, adjusted_difficulties.find (genesis.hash ())->second);
node1.process_active (open_epoch2);
node1.block_processor.flush ();
ASSERT_EQ (12, node1.active.size ());
system.deadline_set (3s);
while (node1.active.size () != 12)
{
ASSERT_NO_ERROR (system.poll ());
}
{
std::lock_guard<std::mutex> guard (node1.active.mutex);
ASSERT_EQ (node1.active.roots.get<1> ().begin ()->election->status.winner->hash (), open_epoch2->hash ());

View file

@ -76,6 +76,7 @@ void nano::active_transactions::request_confirm (std::unique_lock<std::mutex> &
auto transaction (node.store.tx_begin_read ());
unsigned unconfirmed_count (0);
unsigned unconfirmed_announcements (0);
unsigned could_fit_delay = node.network_params.network.is_test_network () ? 10 : 1;
std::unordered_map<std::shared_ptr<nano::transport::channel>, std::vector<std::pair<nano::block_hash, nano::block_hash>>> requests_bundle;
std::deque<std::shared_ptr<nano::block>> rebroadcast_bundle;
std::deque<std::pair<std::shared_ptr<nano::block>, std::shared_ptr<std::vector<std::shared_ptr<nano::transport::channel>>>>> confirm_req_bundle;
@ -141,7 +142,7 @@ void nano::active_transactions::request_confirm (std::unique_lock<std::mutex> &
election_l->update_dependent ();
}
}
if (election_l->announcements < announcement_long || election_l->announcements % announcement_long == 1)
if (election_l->announcements < announcement_long || election_l->announcements % announcement_long == could_fit_delay)
{
if (node.ledger.could_fit (transaction, *election_l->status.winner))
{