From c064dba914ea315411204b6421e1b782f98523e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:42:13 +0200 Subject: [PATCH] More frequent online weight sampling when testing --- nano/core_test/vote_processor.cpp | 11 +++++------ nano/secure/common.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/nano/core_test/vote_processor.cpp b/nano/core_test/vote_processor.cpp index ea9ada7809..797077cc6d 100644 --- a/nano/core_test/vote_processor.cpp +++ b/nano/core_test/vote_processor.cpp @@ -114,8 +114,7 @@ TEST (vote_processor, weights) auto & node (*system.nodes[0]); // Create representatives of different weight levels - // FIXME: Using `online_weight_minimum` because calculation of trended and online weight is broken when running tests - auto const stake = node.config.online_weight_minimum.number (); + auto const stake = node.balance (nano::dev::genesis_key.pub); auto const level0 = stake / 5000; // 0.02% auto const level1 = stake / 500; // 0.2% auto const level2 = stake / 50; // 2% @@ -142,10 +141,10 @@ TEST (vote_processor, weights) node.stats.clear (); ASSERT_TIMELY (5s, node.stats.count (nano::stat::type::rep_tiers, nano::stat::detail::updated) >= 2); - ASSERT_EQ (node.rep_tiers.tier (key0.pub), nano::rep_tier::none); - ASSERT_EQ (node.rep_tiers.tier (key1.pub), nano::rep_tier::tier_1); - ASSERT_EQ (node.rep_tiers.tier (key2.pub), nano::rep_tier::tier_2); - ASSERT_EQ (node.rep_tiers.tier (nano::dev::genesis_key.pub), nano::rep_tier::tier_3); + ASSERT_TIMELY_EQ (5s, node.rep_tiers.tier (key0.pub), nano::rep_tier::none); + ASSERT_TIMELY_EQ (5s, node.rep_tiers.tier (key1.pub), nano::rep_tier::tier_1); + ASSERT_TIMELY_EQ (5s, node.rep_tiers.tier (key2.pub), nano::rep_tier::tier_2); + ASSERT_TIMELY_EQ (5s, node.rep_tiers.tier (nano::dev::genesis_key.pub), nano::rep_tier::tier_3); } // Issue that tracks last changes on this test: https://github.com/nanocurrency/nano-node/issues/3485 diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index d5d071bc91..9b4c7f5ddb 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -255,7 +255,7 @@ nano::node_constants::node_constants (nano::network_constants & network_constant search_pending_interval = network_constants.is_dev_network () ? std::chrono::seconds (1) : std::chrono::seconds (5 * 60); unchecked_cleaning_interval = std::chrono::minutes (30); process_confirmed_interval = network_constants.is_dev_network () ? std::chrono::milliseconds (50) : std::chrono::milliseconds (500); - weight_interval = std::chrono::minutes (5); + weight_interval = network_constants.is_dev_network () ? std::chrono::seconds (1) : std::chrono::minutes (5); weight_cutoff = (network_constants.is_live_network () || network_constants.is_test_network ()) ? std::chrono::weeks (2) : std::chrono::days (1); }