diff --git a/test/fixtures/common_cli_save_results/main.cpp b/test/fixtures/common_cli_save_results/main.cpp index 8ac0867d..2ba8697c 100644 --- a/test/fixtures/common_cli_save_results/main.cpp +++ b/test/fixtures/common_cli_save_results/main.cpp @@ -9,6 +9,7 @@ #include #define MIN_LOCAL_ADVERT_INTERVAL 60 +#define RETRY_PRESET_CUSTOM 0xFF #define PUB_KEY_SIZE 32 #define PRV_KEY_SIZE 64 namespace mesh { @@ -26,6 +27,7 @@ struct Utils { } struct Prefs { uint8_t advert_interval = 30, flood_advert_interval = 12, multi_acks = 0; + uint8_t flood_retry_attempts = 8, retry_preset = 0; char password[16] = "old-admin", guest_password[16] = "old-guest"; bool dirty = true; void clearDirty() { dirty = false; } @@ -45,6 +47,7 @@ struct Callbacks { void savePrefs(PrefsSaveRouting::Scope); void updateAdvertTimer(); void updateFloodAdvertTimer(); + void onRetryConfigChanged() { ++flood_updates; } bool saveIdentity(const mesh::LocalIdentity&) { ++identity_saves; return identity_ok; } }; struct CommonCLI { @@ -58,6 +61,7 @@ struct CommonCLI { void savePrefs(PrefsSaveRouting::Scope scope = PrefsSaveRouting::Scope::Common); bool trySavePrefs(PrefsSaveRouting::Scope scope = PrefsSaveRouting::Scope::Common); bool saveObserverPrefs(); + int _atoi(const char* value) { return std::atoi(value); } void set(const char* config, char* reply); void password(const char* command, char* reply); }; @@ -151,6 +155,25 @@ int main() { } assert(flood ? cli.callbacks.flood_updates == 3 : cli.callbacks.local_updates == 3); } + { + CommonCLI cli; + cli.callbacks.common_ok = false; + cli.set("flood.retry.count 2", reply); + assert(error(reply) && cli.prefs.flood_retry_attempts == 2); + assert(cli.callbacks.persisted.flood_retry_attempts == 8); + assert(cli.callbacks.flood_updates == 1); + cli.callbacks.common_ok = true; + for (const char* value : {"2", "0", "15"}) { + cli.set((std::string("flood.retry.count ") + value).c_str(), reply); + assert(strcmp(reply, "OK") == 0); + assert(cli.prefs.flood_retry_attempts == std::atoi(value)); + assert(cli.callbacks.persisted.flood_retry_attempts == std::atoi(value)); + assert(cli.callbacks.persisted.retry_preset == RETRY_PRESET_CUSTOM); + } + CommonCLI reboot; + reboot.prefs = cli.callbacks.persisted; + assert(reboot.prefs.flood_retry_attempts == 15); + } { CommonCLI cli; const std::string key = "prv.key " + std::string(128, '1'); diff --git a/test/test_build_profiles.sh b/test/test_build_profiles.sh index 135eb653..77c30ac9 100644 --- a/test/test_build_profiles.sh +++ b/test/test_build_profiles.sh @@ -112,7 +112,7 @@ import sys sections = {section: dict(options) for section, options in json.load(sys.stdin)} def option_text(env_name, option_name): - section = sections.get(f"env:{env_name}") + section = sections.get(f"env:{env_name}", sections.get(env_name)) if section is None: raise SystemExit(f"test_build_profiles: missing PlatformIO environment {env_name}") value = section.get(option_name, []) @@ -241,6 +241,8 @@ reject(rc32_repeater, "build_flags", "ESP32_CPU_FREQ=160") # creating a second Wire instance on the same pins as the board bus. require("Heltec_t096_companion_radio_usb_femon", "build_flags", "ENV_PIN_SDA=PIN_WIRE1_SDA") require("Heltec_t096_companion_radio_usb_femon", "build_flags", "ENV_PIN_SCL=PIN_WIRE1_SCL") +require("Heltec_t096", "build_flags", "LORA_TX_POWER=22") +reject("Heltec_t096", "build_flags", "LORA_TX_POWER=9") require("Heltec_v3_companion_radio_wifi", "build_flags", "ENV_PIN_SDA=33") require("Heltec_v3_companion_radio_wifi", "build_flags", "ENV_PIN_SCL=34") diff --git a/test/test_common_cli_save_results.py b/test/test_common_cli_save_results.py index c85c2129..fede00b3 100644 --- a/test/test_common_cli_save_results.py +++ b/test/test_common_cli_save_results.py @@ -35,6 +35,7 @@ class CommonCLISaveResultsTest(unittest.TestCase): branches = '\nelse '.join(extract_braced(source, signature) for signature in ( 'if (memcmp(config, "flood.advert.interval ", 22) == 0)', 'if (memcmp(config, "advert.interval ", 16) == 0)', + 'if (memcmp(config, "flood.retry.count ", 18) == 0)', 'if (memcmp(config, "guest.password ", 15) == 0)', 'if (memcmp(config, "prv.key ", 8) == 0)', 'if (memcmp(config, "multi.acks ", 11) == 0)'))