diff options
| author | Your Name <you@example.com> | 2026-05-23 15:26:52 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-23 15:26:52 +0530 |
| commit | be4d490e96de3d20cc6c9921f09534cde0ca0765 (patch) | |
| tree | 624cdbaff079e14a26fc22f7741a1452b54555b9 /tests/unit/Makefile | |
| parent | 4ce93d0470e8ab2402486c893f50bfdf216752e6 (diff) | |
Phase 8c-8f: Extract portal, stratum_client, mint_health, client into tollgate_core
New component modules:
- tollgate_core_portal.c/h: template rendering, usage calc, captive URI detection
- tollgate_core_stratum_client.c/h: Stratum V1 JSON protocol parsing, message building
- tollgate_core_mint_health.c/h: mint health state tracking, recovery threshold logic
- tollgate_core_client.c/h: discovery/session/usage JSON parsing, renewal check, price calc
Main shims updated to delegate pure logic to component:
- captive_portal.c: uses tollgate_core_portal_render(), format_usage(), is_captive_uri()
- stratum_client.c: uses tollgate_core_stratum_parse_notify/build_*()
- mint_health.c: uses tollgate_core_mint_health_update/is_reachable/mark_unreachable()
- tollgate_client.c: uses tollgate_core_client_parse_*/should_renew/calc_price_per_min()
4 new unit tests (test_portal, test_stratum_client, test_mint_health_core, test_client_core)
All 25 unit tests pass. ESP-IDF build passes (68% partition free).
Diffstat (limited to 'tests/unit/Makefile')
| -rw-r--r-- | tests/unit/Makefile | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tests/unit/Makefile b/tests/unit/Makefile index 9347516..591ec0f 100644 --- a/tests/unit/Makefile +++ b/tests/unit/Makefile | |||
| @@ -26,7 +26,7 @@ LDFLAGS := -lmbedcrypto -lcjson -lm | |||
| 26 | 26 | ||
| 27 | SECP256K1_OBJ := secp256k1.o precomputed_ecmult.o precomputed_ecmult_gen.o | 27 | SECP256K1_OBJ := secp256k1.o precomputed_ecmult.o precomputed_ecmult_gen.o |
| 28 | 28 | ||
| 29 | TESTS := test_geohash test_identity test_nostr_event test_cashu test_session test_tollgate_client test_lnurl_pay test_lightning_payout test_mcp_handler test_nip04 test_cvm_server test_beacon_price test_market test_mint_health test_mining_payment test_stratum_proxy test_session_payment_method test_tollgate_client_mining test_firewall_sandbox test_relay_selector test_relay_validator | 29 | TESTS := test_geohash test_identity test_nostr_event test_cashu test_session test_tollgate_client test_lnurl_pay test_lightning_payout test_mcp_handler test_nip04 test_cvm_server test_beacon_price test_market test_mint_health test_mining_payment test_stratum_proxy test_session_payment_method test_tollgate_client_mining test_firewall_sandbox test_relay_selector test_relay_validator test_portal test_stratum_client test_mint_health_core test_client_core |
| 30 | 30 | ||
| 31 | .PHONY: all test clean $(TESTS) | 31 | .PHONY: all test clean $(TESTS) |
| 32 | 32 | ||
| @@ -69,8 +69,8 @@ TG_CORE_OBJS_CFLAGS := -include stubs/mint_health.h -include stubs/esp_netif.h - | |||
| 69 | test_session: test_session.c $(TG_CORE_SRC)/tollgate_core_cashu.c $(TG_CORE_SRC)/tollgate_core_session.c $(TG_CORE_SRC)/tollgate_core_firewall.c $(TG_CORE_SRC)/tollgate_core.c $(TG_CORE_SRC)/tollgate_core_mining.c $(TG_CORE_SRC)/tollgate_core_dns.c $(TG_CORE_SRC)/tollgate_core_stratum_proxy.c | 69 | test_session: test_session.c $(TG_CORE_SRC)/tollgate_core_cashu.c $(TG_CORE_SRC)/tollgate_core_session.c $(TG_CORE_SRC)/tollgate_core_firewall.c $(TG_CORE_SRC)/tollgate_core.c $(TG_CORE_SRC)/tollgate_core_mining.c $(TG_CORE_SRC)/tollgate_core_dns.c $(TG_CORE_SRC)/tollgate_core_stratum_proxy.c |
| 70 | $(CC) $(CFLAGS) $(TG_CORE_OBJS_CFLAGS) $^ -o $@ $(LDFLAGS) | 70 | $(CC) $(CFLAGS) $(TG_CORE_OBJS_CFLAGS) $^ -o $@ $(LDFLAGS) |
| 71 | 71 | ||
| 72 | test_tollgate_client: test_tollgate_client.c $(REPO_ROOT)/main/market.c $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c $(TG_CORE_SRC)/tollgate_core_market.c | 72 | test_tollgate_client: test_tollgate_client.c $(REPO_ROOT)/main/market.c $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c $(TG_CORE_SRC)/tollgate_core_market.c $(TG_CORE_SRC)/tollgate_core_client.c |
| 73 | $(CC) $(CFLAGS) -I $(REPO_ROOT)/main $< $(REPO_ROOT)/main/market.c $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c $(TG_CORE_SRC)/tollgate_core_market.c -o $@ $(LDFLAGS) | 73 | $(CC) $(CFLAGS) -I $(REPO_ROOT)/main $< $(REPO_ROOT)/main/market.c $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c $(TG_CORE_SRC)/tollgate_core_market.c $(TG_CORE_SRC)/tollgate_core_client.c -o $@ $(LDFLAGS) |
| 74 | 74 | ||
| 75 | test_lnurl_pay: test_lnurl_pay.c | 75 | test_lnurl_pay: test_lnurl_pay.c |
| 76 | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) | 76 | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) |
| @@ -87,8 +87,8 @@ test_nip04: test_nip04.c $(REPO_ROOT)/main/nip04.c $(SECP256K1_OBJ) | |||
| 87 | test_cvm_server: test_cvm_server.c | 87 | test_cvm_server: test_cvm_server.c |
| 88 | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) | 88 | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) |
| 89 | 89 | ||
| 90 | test_mint_health: test_mint_health.c $(REPO_ROOT)/main/mint_health.c | 90 | test_mint_health: test_mint_health.c $(REPO_ROOT)/main/mint_health.c $(TG_CORE_SRC)/tollgate_core_mint_health.c |
| 91 | $(CC) -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-sign-compare -std=gnu17 -g -O0 -DTEST_HOST -include stubs/esp_err.h -I $(REPO_ROOT)/main -I stubs -I $(SECP256K1_INC) -I $(SECP256K1_CFG) -I /usr/include/cjson $< $(REPO_ROOT)/main/mint_health.c -o $@ $(LDFLAGS) | 91 | $(CC) -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-sign-compare -std=gnu17 -g -O0 -DTEST_HOST -include stubs/esp_err.h -I $(REPO_ROOT)/main -I stubs -I $(SECP256K1_INC) -I $(SECP256K1_CFG) -I /usr/include/cjson -I $(TG_CORE_SRC) -I $(TG_CORE_INC) $^ -o $@ $(LDFLAGS) |
| 92 | 92 | ||
| 93 | test_beacon_price: test_beacon_price.c $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c | 93 | test_beacon_price: test_beacon_price.c $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c |
| 94 | $(CC) $(CFLAGS) -I $(REPO_ROOT)/main $< $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c -o $@ $(LDFLAGS) | 94 | $(CC) $(CFLAGS) -I $(REPO_ROOT)/main $< $(REPO_ROOT)/main/beacon_price.c $(TG_CORE_SRC)/tollgate_core_beacon.c -o $@ $(LDFLAGS) |
| @@ -105,8 +105,8 @@ test_stratum_proxy: test_stratum_proxy.c $(REPO_ROOT)/main/stratum_proxy.c $(TG_ | |||
| 105 | test_session_payment_method: test_session_payment_method.c $(TG_CORE_SRC)/tollgate_core_cashu.c $(TG_CORE_SRC)/tollgate_core_session.c $(TG_CORE_SRC)/tollgate_core_firewall.c $(TG_CORE_SRC)/tollgate_core.c $(TG_CORE_SRC)/tollgate_core_mining.c $(TG_CORE_SRC)/tollgate_core_dns.c $(TG_CORE_SRC)/tollgate_core_stratum_proxy.c | 105 | test_session_payment_method: test_session_payment_method.c $(TG_CORE_SRC)/tollgate_core_cashu.c $(TG_CORE_SRC)/tollgate_core_session.c $(TG_CORE_SRC)/tollgate_core_firewall.c $(TG_CORE_SRC)/tollgate_core.c $(TG_CORE_SRC)/tollgate_core_mining.c $(TG_CORE_SRC)/tollgate_core_dns.c $(TG_CORE_SRC)/tollgate_core_stratum_proxy.c |
| 106 | $(CC) $(CFLAGS) $(TG_CORE_OBJS_CFLAGS) $^ -o $@ $(LDFLAGS) | 106 | $(CC) $(CFLAGS) $(TG_CORE_OBJS_CFLAGS) $^ -o $@ $(LDFLAGS) |
| 107 | 107 | ||
| 108 | test_tollgate_client_mining: test_tollgate_client_mining.c | 108 | test_tollgate_client_mining: test_tollgate_client_mining.c $(TG_CORE_SRC)/tollgate_core_client.c |
| 109 | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) | 109 | $(CC) $(CFLAGS) -I $(REPO_ROOT)/main $< $(TG_CORE_SRC)/tollgate_core_client.c -o $@ $(LDFLAGS) |
| 110 | 110 | ||
| 111 | test_firewall_sandbox: test_firewall_sandbox.c $(TG_CORE_SRC)/tollgate_core_firewall.c $(TG_CORE_SRC)/tollgate_core.c $(TG_CORE_SRC)/tollgate_core_session.c $(TG_CORE_SRC)/tollgate_core_cashu.c $(TG_CORE_SRC)/tollgate_core_mining.c $(TG_CORE_SRC)/tollgate_core_dns.c $(TG_CORE_SRC)/tollgate_core_stratum_proxy.c | 111 | test_firewall_sandbox: test_firewall_sandbox.c $(TG_CORE_SRC)/tollgate_core_firewall.c $(TG_CORE_SRC)/tollgate_core.c $(TG_CORE_SRC)/tollgate_core_session.c $(TG_CORE_SRC)/tollgate_core_cashu.c $(TG_CORE_SRC)/tollgate_core_mining.c $(TG_CORE_SRC)/tollgate_core_dns.c $(TG_CORE_SRC)/tollgate_core_stratum_proxy.c |
| 112 | $(CC) $(CFLAGS) -include stubs/dns_server.h $(TG_CORE_OBJS_CFLAGS) $^ -o $@ $(LDFLAGS) | 112 | $(CC) $(CFLAGS) -include stubs/dns_server.h $(TG_CORE_OBJS_CFLAGS) $^ -o $@ $(LDFLAGS) |
| @@ -117,5 +117,17 @@ test_relay_selector: test_relay_selector.c | |||
| 117 | test_relay_validator: test_relay_validator.c $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT)/main/identity.c $(REPO_ROOT)/components/wisp_relay/relay_validator.c $(SECP256K1_OBJ) | 117 | test_relay_validator: test_relay_validator.c $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT)/main/identity.c $(REPO_ROOT)/components/wisp_relay/relay_validator.c $(SECP256K1_OBJ) |
| 118 | $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) -I $(REPO_ROOT)/main -I $(REPO_ROOT)/components/wisp_relay $< $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT)/main/identity.c $(REPO_ROOT)/components/wisp_relay/relay_validator.c $(SECP256K1_OBJ) -o $@ $(LDFLAGS) | 118 | $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) -I $(REPO_ROOT)/main -I $(REPO_ROOT)/components/wisp_relay $< $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT)/main/identity.c $(REPO_ROOT)/components/wisp_relay/relay_validator.c $(SECP256K1_OBJ) -o $@ $(LDFLAGS) |
| 119 | 119 | ||
| 120 | test_portal: test_portal.c $(TG_CORE_SRC)/tollgate_core_portal.c | ||
| 121 | $(CC) $(CFLAGS) $(TG_CORE_OBJS_CFLAGS) $^ -o $@ $(LDFLAGS) | ||
| 122 | |||
| 123 | test_stratum_client: test_stratum_client.c $(TG_CORE_SRC)/tollgate_core_stratum_client.c | ||
| 124 | $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) | ||
| 125 | |||
| 126 | test_mint_health_core: test_mint_health_core.c $(TG_CORE_SRC)/tollgate_core_mint_health.c | ||
| 127 | $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) | ||
| 128 | |||
| 129 | test_client_core: test_client_core.c $(TG_CORE_SRC)/tollgate_core_client.c | ||
| 130 | $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) | ||
| 131 | |||
| 120 | clean: | 132 | clean: |
| 121 | rm -f $(TESTS) $(SECP256K1_OBJ) | 133 | rm -f $(TESTS) $(SECP256K1_OBJ) |