upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tests/unit/test_session_payment_method
AgeCommit message (Collapse)Author
2026-05-23Phase 7: eliminate shims - consumer files use component headers directlyYour Name
- Deleted standalone shims: session.c/h, cashu.c/h, mining_payment.c/h, firewall.c/h - Updated captive_portal.c, tollgate_api.c, tollgate_main.c, mcp_handler.c, cvm_server.c, sw_miner.c, stratum_client.c to include component headers - Moved tollgate_ip4_canforward_filter() lwIP hook into tollgate_main.c - Fixed all unit tests to use component API (test_cashu, test_session, test_mining_payment, test_stratum_proxy, test_session_payment_method, test_firewall_sandbox, test_mcp_handler) - Removed deleted source files from Makefile targets - All 21 unit tests pass, ESP-IDF build passes
2026-05-23Phase 6e-6f: Break circular dependenciesYour Name
6e: Extract tls_worker queue from tollgate_api.c into shared tls_worker.c/h - mint_health.c no longer includes tollgate_api.h - tollgate_api.c no longer defines tls_worker functions - Clean circular dependency broken 6f: Move payout_config_t from lightning_payout.h to config.h - config.h no longer includes lightning_payout.h - lightning_payout.h includes config.h for types - Reverse dependency broken All 21 unit tests pass. ESP-IDF build passes.
2026-05-23Phase 6a-6d: Consolidate and clean upYour Name
6a: Delete dead standalone tollgate_core/ (12 files, never compiled) 6b: Rewrite dns_server.c as thin shim to component's tollgate_core_dns - Fix component DNS to bind to AP IP instead of INADDR_ANY 6c: Rewrite stratum_proxy.c as thin shim with struct cast to component types 6d: Move sandbox logic into component's tollgate_core_firewall - Add tollgate_core_fw_set_sandbox_ports/set_sandbox_mint_access - Add is_sandbox_allowed() to component's ip4_canforward_filter - Clean main/firewall.c to delegate filter to component - Remove redundant DNS auth double-calls from main firewall Add ROADMAP.md with full extraction plan and checklists All 21 unit tests pass. ESP-IDF build passes.
2026-05-23feat: create tollgate_core standalone C library + tollgate_esp IDF componentYour Name
Phase 1-4: Extract core business logic into reusable library tollgate_core/ — standalone C library (zero ESP-IDF deps): - tollgate_core.c — orchestrator (init, process_payment, process_share, tick) - tollgate_cashu.c — V3 token decode, checkstate via platform callback, allotment math - tollgate_session.c — session lifecycle state machine (create/find/revoke/extend) - tollgate_firewall.c — client allowlist, NAT filter, packet filter - tollgate_mining.c — hashprice, nbits→difficulty, shares-to-allotment, client stats components/tollgate_esp/ — ESP-IDF component wrapper: - tollgate_esp_platform.c — implements tollgate_platform_t using ESP-IDF APIs - CMakeLists.txt — compiles tollgate_core + ESP wrapper, links to ESP-IDF - idf_component.yml — for IDF Component Registry Platform interface (tollgate_platform.h): - Config access: price, step_size, mint_url, metric - Time: get_time_ms (via FreeRTOS ticks on ESP) - Logging: log_info/warn/error (via ESP_LOG on ESP) - Wallet: receive/send/balance (via nucula on ESP) - HTTP: http_post (via esp_http_client on ESP) - WiFi/MAC: mac_for_ip, napt_enable - Mining: stratum config, hashprice override Build verification: - tollgate_core compiles standalone: cmake + make (gcc, host) - tollgate_esp + ESP-IDF full build: passes (idf.py build) - Unit tests: 22/22 pass (make test-unit) - No behavioral change to existing main/ code yet (Phase 5)
2026-05-23chore: fix unit test build rules, add relay_selector+relay_validator tests, ↵HEADmasterYour Name
persist core extraction plan
2026-05-21Wallet receive via health task queue (no separate TLS worker)Your Name
- Removed standalone TLS worker task (couldn't allocate 16KB internal stack) - Added wallet receive queue to mint_health task (already has 16KB stack + working TLS) - health_task processes wallet tokens between probe intervals (1s poll) - tls_worker_set_queue() registers queue from mint_health_start() - Fallback to synchronous receive if queue not available - Added freertos/queue.h and tollgate_api.h stubs for unit tests - Added BaseType_t/UBaseType_t/TickType_t/pdFALSE to FreeRTOS stub - Full payment round-trip confirmed: 2 payments → 41 sat balance
2026-05-20chore: remove compiled test binaries from git trackingYour Name
2026-05-19fix: resolve merge conflicts + test build fixesYour Name
- config.h: remove duplicate nostr_sync fields - Makefile: add mint_health stub for test_session_payment_method - test_tollgate_client_mining: inline market_t stub to avoid dependency cascade - CMakeLists: add negentropy_adapter.c + esp_littlefs + negentropy REQUIRES
2026-05-19feat(mining): Bitcoin mining-for-bandwidth payment systemYour Name
New modules: - mining_payment.c/h: hashprice calc (nbits->difficulty->sat/GH/s/day), share validation, client stats, allotment conversion (ms + bytes) - stratum_client.c/h: SV1 upstream pool connection (subscribe/authorize/submit) - stratum_proxy.c/h: Local SV1 TCP server for downstream miners, job broadcast - sw_miner.c/h: Software SHA256d miner (ESP32 CPU fallback) - asic_miner.c/h: ASIC detection stub (BM1366/BM1368 SPI) Config: - config.h/c: mining_payout_mode_t enum (auto/pool/upstream/proxy_only), stratum pool settings, mining port, hashprice override, sandbox mint access - Defaults fill nostr_seed_relays (8/8) and nostr_relays (4/4) with fast relays Integration into existing modules: - session.h/c: payment_method_t enum (CASHU/MINING/BYTES) - firewall.h/c: firewall_set_mining_port(), firewall_set_sandbox_mint_access() - tollgate_api.c: GET /mining/job, POST /mining/share, GET /mining/stats - tollgate_client.h/c: TG_CLIENT_MINING state, mining discovery tag parsing - tollgate_main.c: mining init in start_services(), stratum_client_tick() in loop - captive_portal.c: tabbed Cashu/Mine UI with live hashrate polling Unit tests (69 new assertions across 4 suites): - test_mining_payment (23 tests): nbits->difficulty, hashprice, client stats, allotment - test_stratum_proxy (21 tests): job set/get, stats, type validation - test_session_payment_method (12 tests): PAYMENT_METHOD enum, bytes/cashu methods - test_tollgate_client_mining (20 tests): mining tag parsing, discovery struct - test_firewall_sandbox (16 tests): client grant/revoke, max clients, setters Enhanced test stubs: - BaseType_t/pdPASS in freertos/task.h - lwip: sockets.h, etharp.h, prot/ip.h, prot/ip4.h, prot/tcp.h, netif.h - dns_server.h, esp_wifi_ap_get_sta_list.h Build fixes: - cvm_server.c: replace esp_timer_get_time() with xTaskGetTickCount(), fix process_relay_message() 3-arg call to 2-arg, add WS keepalive ping - stratum_proxy.c: widen task_name buffer 16->20 - sw_miner.c: add missing #include esp_random.h - nucula_src: save_proofs() moved to public in wallet.hpp Nostr relay updates: - nostr_seed_relays: +relay.anzenkodo.workers.dev, +nostr.koning-degraaf.nl, +knostr.neutrine.com, +nostr.einundzwanzig.space (8/8 slots) - nostr_relays: +relay.anzenkodo.workers.dev, +nostr.koning-degraaf.nl (4/4 slots) Squash-merge of feature/mining-payment (5 commits: c75230e..9d98ba1)