go-proxy/config_runtime_test.go
Virgil 8579b0cc11 fix(proxy): relax config validation and dedupe disconnects
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 11:36:27 +00:00

38 lines
964 B
Go

package proxy
import "testing"
func TestConfig_Validate_Good(t *testing.T) {
cfg := &Config{
Mode: "nicehash",
Bind: []BindAddr{{Host: "127.0.0.1", Port: 3333}},
Pools: []PoolConfig{{URL: "pool-a:3333", Enabled: true}},
}
if errorValue := cfg.Validate(); errorValue != nil {
t.Fatalf("expected valid config, got %v", errorValue)
}
}
func TestConfig_Validate_Bad(t *testing.T) {
cfg := &Config{
Bind: []BindAddr{{Host: "127.0.0.1", Port: 3333}},
Pools: []PoolConfig{{URL: "pool-a:3333", Enabled: true}},
}
if errorValue := cfg.Validate(); errorValue != nil {
t.Fatalf("expected missing mode to be allowed, got %v", errorValue)
}
}
func TestConfig_Validate_Ugly(t *testing.T) {
cfg := &Config{
Mode: "simple",
Bind: []BindAddr{{Host: "127.0.0.1", Port: 3333}},
Pools: []PoolConfig{{Enabled: true}},
}
if errorValue := cfg.Validate(); errorValue == nil {
t.Fatal("expected empty enabled pool URL to fail validation")
}
}