fix(proxy): omit null errors from success replies

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 21:37:15 +00:00
parent 1548643c65
commit c62f2c86a9
2 changed files with 37 additions and 2 deletions

View file

@ -226,6 +226,43 @@ func TestMiner_HandleLogin_CustomDiffCap_Good(t *testing.T) {
}
}
func TestMiner_HandleKeepalived_Good(t *testing.T) {
minerConn, clientConn := net.Pipe()
defer minerConn.Close()
defer clientConn.Close()
miner := NewMiner(minerConn, 3333, nil)
done := make(chan struct{})
go func() {
miner.handleKeepalived(stratumRequest{ID: 9, Method: "keepalived"})
close(done)
}()
line, err := bufio.NewReader(clientConn).ReadBytes('\n')
if err != nil {
t.Fatalf("read keepalived response: %v", err)
}
<-done
var payload map[string]json.RawMessage
if err := json.Unmarshal(line, &payload); err != nil {
t.Fatalf("unmarshal keepalived response: %v", err)
}
if _, ok := payload["error"]; ok {
t.Fatalf("expected keepalived response to omit error field, got %s", string(line))
}
var result struct {
Status string `json:"status"`
}
if err := json.Unmarshal(payload["result"], &result); err != nil {
t.Fatalf("unmarshal keepalived result: %v", err)
}
if result.Status != "KEEPALIVED" {
t.Fatalf("expected KEEPALIVED status, got %q", result.Status)
}
}
func TestMiner_ReadLoop_RFCLineLimit_Good(t *testing.T) {
minerConn, clientConn := net.Pipe()
defer minerConn.Close()

View file

@ -1090,7 +1090,6 @@ func (m *Miner) replyLoginSuccess(id int64) {
payload := map[string]any{
"id": id,
"jsonrpc": "2.0",
"error": nil,
"result": result,
}
_ = m.writeJSON(payload)
@ -1138,7 +1137,6 @@ func (m *Miner) Success(id int64, status string) {
payload := map[string]any{
"id": id,
"jsonrpc": "2.0",
"error": nil,
"result": map[string]any{
"status": status,
},