upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-18 14:53:12 +0530
committerYour Name <you@example.com>2026-05-18 14:53:12 +0530
commit6faa3cef6cc6206cc1579ad71f1042857a6d38d6 (patch)
tree2e659a31a4f261a1f7d041d68b633e0bbf64a1f3
parent2a86bec93273e2f4ceeab60683058c65dbb1da3d (diff)
test: add mint_health stub for host unit tests, fix test_cashu build
-rw-r--r--tests/unit/Makefile4
-rw-r--r--tests/unit/stubs/mint_health.h44
2 files changed, 46 insertions, 2 deletions
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
58 $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) $< $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT)/main/identity.c $(SECP256K1_OBJ) -o $@ $(LDFLAGS) 58 $(CC) $(CFLAGS) -I $(SECP256K1_PRIV_INC) $< $(REPO_ROOT)/main/nostr_event.c $(REPO_ROOT)/main/identity.c $(SECP256K1_OBJ) -o $@ $(LDFLAGS)
59 59
60test_cashu: test_cashu.c $(REPO_ROOT)/main/cashu.c 60test_cashu: test_cashu.c $(REPO_ROOT)/main/cashu.c
61 $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS) 61 $(CC) $(CFLAGS) -include stubs/mint_health.h $< $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS)
62 62
63test_session: test_session.c $(REPO_ROOT)/main/session.c $(REPO_ROOT)/main/cashu.c 63test_session: test_session.c $(REPO_ROOT)/main/session.c $(REPO_ROOT)/main/cashu.c
64 $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/session.c $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS) 64 $(CC) $(CFLAGS) -include stubs/mint_health.h $< $(REPO_ROOT)/main/session.c $(REPO_ROOT)/main/cashu.c -o $@ $(LDFLAGS)
65 65
66test_tollgate_client: test_tollgate_client.c 66test_tollgate_client: test_tollgate_client.c
67 $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) 67 $(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 @@
1#ifndef MINT_HEALTH_H
2#define MINT_HEALTH_H
3
4#include <stdbool.h>
5#include <stdint.h>
6
7#define MINT_HEALTH_MAX 8
8#define MINT_HEALTH_PROBE_INTERVAL_S 300
9#define MINT_HEALTH_PROBE_TIMEOUT_MS 15000
10#define MINT_HEALTH_RECOVERY_THRESHOLD 3
11
12typedef struct {
13 char url[256];
14 bool reachable;
15 uint8_t consecutive_successes;
16 int64_t last_probe_ms;
17 int last_http_status;
18} mint_status_t;
19
20typedef void (*mint_health_changed_cb)(void);
21
22static inline bool mint_health_is_reachable(const char *url) {
23 (void)url;
24 return true;
25}
26
27static inline void mint_health_mark_unreachable(const char *url) {
28 (void)url;
29}
30
31static inline esp_err_t mint_health_init(const char urls[][256], int count) {
32 (void)urls; (void)count; return 0;
33}
34
35static inline void mint_health_start(void) {}
36static inline void mint_health_stop(void) {}
37static inline const mint_status_t *mint_health_get_all(int *out_count) {
38 *out_count = 0; return NULL;
39}
40static inline void mint_health_register_callback(mint_health_changed_cb cb) {
41 (void)cb;
42}
43
44#endif