From ef9ae982e42cd8c719a8ba5a0b87f25a5a5f91ba Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 May 2026 13:10:54 +0530 Subject: test: add 4 new unit test suites for mining modules - test_stratum_proxy: job set/get, stats, init (21 tests) - test_session_payment_method: PAYMENT_METHOD enum, bytes/cashu methods (12 tests) - test_tollgate_client_mining: mining tag parsing, discovery struct (20 tests) - test_firewall_sandbox: client management, grant/revoke, max clients (16 tests) - Enhanced stubs: BaseType_t/pdPASS in task.h, lwip sockets/etharp/prot headers, dns_server.h, esp_wifi_ap_get_sta_list.h - All 15 test suites pass (344+ total assertions) --- tests/unit/stubs/lwip/etharp.h | 22 ++++++++++++++++++++++ tests/unit/stubs/lwip/ip4_addr.h | 3 +++ tests/unit/stubs/lwip/lwip_napt.h | 6 ++++++ tests/unit/stubs/lwip/napt.h | 6 ------ tests/unit/stubs/lwip/netif.h | 16 ++++++++++++++++ tests/unit/stubs/lwip/prot/ip.h | 20 ++++++++++++++++++++ tests/unit/stubs/lwip/prot/ip4.h | 6 ++++++ tests/unit/stubs/lwip/prot/tcp.h | 13 +++++++++++++ tests/unit/stubs/lwip/sockets.h | 6 ++++++ 9 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 tests/unit/stubs/lwip/etharp.h create mode 100644 tests/unit/stubs/lwip/lwip_napt.h delete mode 100644 tests/unit/stubs/lwip/napt.h create mode 100644 tests/unit/stubs/lwip/prot/ip.h create mode 100644 tests/unit/stubs/lwip/prot/ip4.h create mode 100644 tests/unit/stubs/lwip/prot/tcp.h (limited to 'tests/unit/stubs/lwip') diff --git a/tests/unit/stubs/lwip/etharp.h b/tests/unit/stubs/lwip/etharp.h new file mode 100644 index 0000000..adc6b7b --- /dev/null +++ b/tests/unit/stubs/lwip/etharp.h @@ -0,0 +1,22 @@ +#ifndef STUBS_LWIP_ETHARP_H +#define STUBS_LWIP_ETHARP_H + +#include +#include +#include "lwip/ip4_addr.h" + +struct eth_addr { + uint8_t addr[6]; +}; + +struct netif; + +typedef int err_t; +#define ERR_OK 0 + +static inline err_t etharp_get_entry(ssize_t i, ip4_addr_t **ip, struct netif **netif, struct eth_addr **eth) { + (void)i; (void)ip; (void)netif; (void)eth; + return -1; +} + +#endif diff --git a/tests/unit/stubs/lwip/ip4_addr.h b/tests/unit/stubs/lwip/ip4_addr.h index 174211b..9d92ff0 100644 --- a/tests/unit/stubs/lwip/ip4_addr.h +++ b/tests/unit/stubs/lwip/ip4_addr.h @@ -3,6 +3,9 @@ #include +typedef uint32_t u32_t; +typedef uint16_t u16_t; + typedef struct { uint32_t addr; } ip4_addr_t; diff --git a/tests/unit/stubs/lwip/lwip_napt.h b/tests/unit/stubs/lwip/lwip_napt.h new file mode 100644 index 0000000..c6a5ca1 --- /dev/null +++ b/tests/unit/stubs/lwip/lwip_napt.h @@ -0,0 +1,6 @@ +#ifndef STUBS_LWIP_NAPT_H +#define STUBS_LWIP_NAPT_H + +static inline void ip_napt_enable(uint32_t num, int enable) { (void)num; (void)enable; } + +#endif diff --git a/tests/unit/stubs/lwip/napt.h b/tests/unit/stubs/lwip/napt.h deleted file mode 100644 index c6a5ca1..0000000 --- a/tests/unit/stubs/lwip/napt.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef STUBS_LWIP_NAPT_H -#define STUBS_LWIP_NAPT_H - -static inline void ip_napt_enable(uint32_t num, int enable) { (void)num; (void)enable; } - -#endif diff --git a/tests/unit/stubs/lwip/netif.h b/tests/unit/stubs/lwip/netif.h index 461a64e..9415539 100644 --- a/tests/unit/stubs/lwip/netif.h +++ b/tests/unit/stubs/lwip/netif.h @@ -1,4 +1,20 @@ #ifndef STUBS_LWIP_NETIF_H #define STUBS_LWIP_NETIF_H +#include +#include + +struct pbuf { + void *payload; + uint16_t len; +}; + +static inline uint32_t lwip_ntohl(uint32_t n) { + return ((n & 0xFF) << 24) | ((n & 0xFF00) << 8) | ((n >> 8) & 0xFF00) | ((n >> 24) & 0xFF); +} + +static inline uint16_t lwip_ntohs(uint16_t n) { + return ((n & 0xFF) << 8) | ((n >> 8) & 0xFF); +} + #endif diff --git a/tests/unit/stubs/lwip/prot/ip.h b/tests/unit/stubs/lwip/prot/ip.h new file mode 100644 index 0000000..0770760 --- /dev/null +++ b/tests/unit/stubs/lwip/prot/ip.h @@ -0,0 +1,20 @@ +#ifndef STUBS_LWIP_PROT_IP_H +#define STUBS_LWIP_PROT_IP_H + +#include + +#define IP_PROTO_TCP 6 +#define IP_PROTO_UDP 17 +#define IP_HLEN 20 + +struct ip_hdr { + uint8_t _proto; + union { + uint32_t addr; + } src; + union { + uint32_t addr; + } dest; +}; + +#endif diff --git a/tests/unit/stubs/lwip/prot/ip4.h b/tests/unit/stubs/lwip/prot/ip4.h new file mode 100644 index 0000000..0f70170 --- /dev/null +++ b/tests/unit/stubs/lwip/prot/ip4.h @@ -0,0 +1,6 @@ +#ifndef STUBS_LWIP_PROT_IP4_H +#define STUBS_LWIP_PROT_IP4_H + +#include "ip.h" + +#endif diff --git a/tests/unit/stubs/lwip/prot/tcp.h b/tests/unit/stubs/lwip/prot/tcp.h new file mode 100644 index 0000000..5841371 --- /dev/null +++ b/tests/unit/stubs/lwip/prot/tcp.h @@ -0,0 +1,13 @@ +#ifndef STUBS_LWIP_PROT_TCP_H +#define STUBS_LWIP_PROT_TCP_H + +#include + +#define TCP_HLEN 20 + +struct tcp_hdr { + uint16_t src; + uint16_t dest; +}; + +#endif diff --git a/tests/unit/stubs/lwip/sockets.h b/tests/unit/stubs/lwip/sockets.h index 44f03ac..91bf8b2 100644 --- a/tests/unit/stubs/lwip/sockets.h +++ b/tests/unit/stubs/lwip/sockets.h @@ -1,4 +1,10 @@ #ifndef STUBS_LWIP_SOCKETS_H #define STUBS_LWIP_SOCKETS_H +#include +#include +#include +#include +#include + #endif -- cgit v1.2.3