Ensure infrastructure role-based minimums are coerced since they don't have scaling (#9937)
* Ensure infrastructure role-based minimums are coerced since they don't have scaling * Add test * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
GitHub
Copilot Autofix powered by AI
parent
aebcb34c80
commit
4fbd5c9f80
@@ -10,8 +10,9 @@ static uint32_t computeExpectedMs(uint32_t defaultSeconds, uint32_t numOnlineNod
|
||||
{
|
||||
uint32_t baseMs = Default::getConfiguredOrDefaultMs(0, defaultSeconds);
|
||||
|
||||
// Routers don't scale
|
||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) {
|
||||
// Routers (including ROUTER_LATE) don't scale
|
||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_LATE) {
|
||||
return baseMs;
|
||||
}
|
||||
|
||||
@@ -93,6 +94,39 @@ void test_client_medium_fast_preset_scaling()
|
||||
TEST_ASSERT_INT_WITHIN(1, expected, res);
|
||||
}
|
||||
|
||||
void test_router_uses_router_minimums()
|
||||
{
|
||||
config.device.role = meshtastic_Config_DeviceConfig_Role_ROUTER;
|
||||
|
||||
uint32_t telemetry = Default::getConfiguredOrMinimumValue(60, min_default_telemetry_interval_secs);
|
||||
uint32_t position = Default::getConfiguredOrMinimumValue(60, min_default_broadcast_interval_secs);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(ONE_DAY / 2, telemetry);
|
||||
TEST_ASSERT_EQUAL_UINT32(ONE_DAY / 2, position);
|
||||
}
|
||||
|
||||
void test_router_late_uses_router_minimums()
|
||||
{
|
||||
config.device.role = meshtastic_Config_DeviceConfig_Role_ROUTER_LATE;
|
||||
|
||||
uint32_t telemetry = Default::getConfiguredOrMinimumValue(60, min_default_telemetry_interval_secs);
|
||||
uint32_t position = Default::getConfiguredOrMinimumValue(60, min_default_broadcast_interval_secs);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(ONE_DAY / 2, telemetry);
|
||||
TEST_ASSERT_EQUAL_UINT32(ONE_DAY / 2, position);
|
||||
}
|
||||
|
||||
void test_client_uses_public_channel_minimums()
|
||||
{
|
||||
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
||||
|
||||
uint32_t telemetry = Default::getConfiguredOrMinimumValue(60, min_default_telemetry_interval_secs);
|
||||
uint32_t position = Default::getConfiguredOrMinimumValue(60, min_default_broadcast_interval_secs);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(30 * 60, telemetry);
|
||||
TEST_ASSERT_EQUAL_UINT32(60 * 60, position);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Small delay to match other test mains
|
||||
@@ -103,6 +137,9 @@ void setup()
|
||||
RUN_TEST(test_client_below_threshold);
|
||||
RUN_TEST(test_client_default_preset_scaling);
|
||||
RUN_TEST(test_client_medium_fast_preset_scaling);
|
||||
RUN_TEST(test_router_uses_router_minimums);
|
||||
RUN_TEST(test_router_late_uses_router_minimums);
|
||||
RUN_TEST(test_client_uses_public_channel_minimums);
|
||||
exit(UNITY_END());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user