From 6faa3cef6cc6206cc1579ad71f1042857a6d38d6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 May 2026 14:53:12 +0530 Subject: test: add mint_health stub for host unit tests, fix test_cashu build --- tests/unit/Makefile | 4 ++-- tests/unit/stubs/mint_health.h | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/unit/stubs/mint_health.h (limited to 'tests') diff --git a/tests/unit/Makefile b/tests/unit/Makefile index 7ebc3b2..f47ef23 100644 --- a/tests/unit/Makefile +++ b/tests/unit/Makefile @@ -58,10 +58,10 @@ test_nostr_event: test_nostr_event.c $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) $< $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT)/main/identity.c $(SECP256K1_OBJ) -o $@ $(LDFLAGS) test_cashu: test_cashu.c $(REPO_ROOT)/main/cashu.c - $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) -include stubs/mint_health.h $< $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS) test_session: test_session.c $(REPO_ROOT)/main/session.c $(REPO_ROOT)/main/cashu.c - $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/session.c $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS) + $(CC) $(CFLAGS) -include stubs/mint_health.h $< $(REPO_ROOT)/main/session.c $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS) test_tollgate_client: test_tollgate_client.c $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/unit/stubs/mint_health.h b/tests/unit/stubs/mint_health.h new file mode 100644 index 0000000..7248042 --- /dev/null +++ b/tests/unit/stubs/mint_health.h @@ -0,0 +1,44 @@ +#ifndef MINT_HEALTH_H +#define MINT_HEALTH_H + +#include +#include + +#define MINT_HEALTH_MAX 8 +#define MINT_HEALTH_PROBE_INTERVAL_S 300 +#define MINT_HEALTH_PROBE_TIMEOUT_MS 15000 +#define MINT_HEALTH_RECOVERY_THRESHOLD 3 + +typedef struct { + char url[256]; + bool reachable; + uint8_t consecutive_successes; + int64_t last_probe_ms; + int last_http_status; +} mint_status_t; + +typedef void (*mint_health_changed_cb)(void); + +static inline bool mint_health_is_reachable(const char *url) { + (void)url; + return true; +} + +static inline void mint_health_mark_unreachable(const char *url) { + (void)url; +} + +static inline esp_err_t mint_health_init(const char urls[][256], int count) { + (void)urls; (void)count; return 0; +} + +static inline void mint_health_start(void) {} +static inline void mint_health_stop(void) {} +static inline const mint_status_t *mint_health_get_all(int *out_count) { + *out_count = 0; return NULL; +} +static inline void mint_health_register_callback(mint_health_changed_cb cb) { + (void)cb; +} + +#endif -- cgit v1.2.3