diff options
| author | Your Name <you@example.com> | 2026-05-19 13:21:25 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 13:31:08 +0530 |
| commit | eeba74a4a1c011e85e33dea4252b381e35a64ea4 (patch) | |
| tree | 14862e7d300511e28e214c743fd2f699bc54c5b8 /tests/unit/test_cashu.c | |
| parent | b0d9d494f00ee77f9efc22d1ef2ea3c94b23ddbd (diff) | |
feat: multi-mint wallet with health tracking, WPA auto-detect, display gating
Squash merge of feature/multi-mint-support (21 commits):
Multi-mint wallet:
- Accept payments from 4 mints: minibits, coinos, 21mint, lnvoltz
- Periodic health probing (300s interval, 3 recovery threshold)
- Multi-wallet init with nucula_wallet_init_multi()
- /mints and /wallet API endpoints
WPA auto-detect:
- wifi_auth_mode config field (default WPA2, supports WPA3)
- Runtime mapping to wifi_auth_mode_t in STA config
Display gating:
- display_enabled config field (default true)
- Guards display_init/display_update per-board
Bug fixes:
- 3s delay before service start prevents lwip mem_free assertion
- Real npub in discovery (identity_get()->npub_hex)
- Health probe interval 300s (production value)
- Duplicate services_start_task call removed
- UTF-8 arrow replaced with ASCII in log message
Tests: 61+14 unit tests passing, firmware builds clean
Diffstat (limited to 'tests/unit/test_cashu.c')
| -rw-r--r-- | tests/unit/test_cashu.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/unit/test_cashu.c b/tests/unit/test_cashu.c index cec8e08..021d1b7 100644 --- a/tests/unit/test_cashu.c +++ b/tests/unit/test_cashu.c | |||
| @@ -20,6 +20,18 @@ int main(void) | |||
| 20 | g_test_config.price_per_step = 21; | 20 | g_test_config.price_per_step = 21; |
| 21 | g_test_config.step_size_ms = 60000; | 21 | g_test_config.step_size_ms = 60000; |
| 22 | 22 | ||
| 23 | const char *mints[] = { | ||
| 24 | "https://testnut.cashu.space", | ||
| 25 | "https://mint.minibits.cash/Bitcoin", | ||
| 26 | "https://mint.coinos.io", | ||
| 27 | "https://21mint.me", | ||
| 28 | }; | ||
| 29 | for (int i = 0; i < 4; i++) { | ||
| 30 | strncpy(g_test_config.accepted_mints[i], mints[i], | ||
| 31 | sizeof(g_test_config.accepted_mints[i]) - 1); | ||
| 32 | } | ||
| 33 | g_test_config.accepted_mint_count = 4; | ||
| 34 | |||
| 23 | printf("\n--- cashu_calculate_allotment_ms ---\n"); | 35 | printf("\n--- cashu_calculate_allotment_ms ---\n"); |
| 24 | uint64_t a1 = cashu_calculate_allotment_ms(21, 21, 60000); | 36 | uint64_t a1 = cashu_calculate_allotment_ms(21, 21, 60000); |
| 25 | ASSERT_EQ_INT(60000, (int)a1, "21 sats at 21 sats/min = 60000ms"); | 37 | ASSERT_EQ_INT(60000, (int)a1, "21 sats at 21 sats/min = 60000ms"); |
| @@ -33,10 +45,14 @@ int main(void) | |||
| 33 | uint64_t a4 = cashu_calculate_allotment_ms(100, 10, 30000); | 45 | uint64_t a4 = cashu_calculate_allotment_ms(100, 10, 30000); |
| 34 | ASSERT_EQ_INT(300000, (int)a4, "100 sats at 10 sats/30s = 300000ms"); | 46 | ASSERT_EQ_INT(300000, (int)a4, "100 sats at 10 sats/30s = 300000ms"); |
| 35 | 47 | ||
| 36 | printf("\n--- cashu_is_mint_accepted ---\n"); | 48 | printf("\n--- cashu_is_mint_accepted (multi-mint) ---\n"); |
| 37 | ASSERT(cashu_is_mint_accepted("https://testnut.cashu.space"), "testnut.cashu.space accepted"); | 49 | ASSERT(cashu_is_mint_accepted("https://testnut.cashu.space"), "testnut.cashu.space accepted"); |
| 50 | ASSERT(cashu_is_mint_accepted("https://mint.minibits.cash/Bitcoin"), "minibits accepted"); | ||
| 51 | ASSERT(cashu_is_mint_accepted("https://mint.coinos.io"), "coinos accepted"); | ||
| 52 | ASSERT(cashu_is_mint_accepted("https://21mint.me"), "21mint accepted"); | ||
| 38 | ASSERT(!cashu_is_mint_accepted("https://evil.mint.example.com"), "evil mint rejected"); | 53 | ASSERT(!cashu_is_mint_accepted("https://evil.mint.example.com"), "evil mint rejected"); |
| 39 | ASSERT(!cashu_is_mint_accepted(""), "empty string rejected"); | 54 | ASSERT(!cashu_is_mint_accepted(""), "empty string rejected"); |
| 55 | ASSERT(!cashu_is_mint_accepted(NULL), "NULL rejected"); | ||
| 40 | 56 | ||
| 41 | printf("\n--- cashu_decode_token with garbage ---\n"); | 57 | printf("\n--- cashu_decode_token with garbage ---\n"); |
| 42 | cashu_token_t token; | 58 | cashu_token_t token; |