fixed persistence error and error with clients sometimes not showing up as connected.

This commit is contained in:
KingKDot
2026-03-08 16:08:04 -05:00
parent ef0ca2994f
commit ed32444495
4 changed files with 44 additions and 2 deletions
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"testing"
"time"
"overlord-client/cmd/agent/config"
rt "overlord-client/cmd/agent/runtime"
@@ -18,6 +19,7 @@ func TestHandlePing(t *testing.T) {
Conn: writer,
Cfg: config.Config{},
}
env.SetLastPong(0)
ctx := context.Background()
envelope := map[string]interface{}{
@@ -44,6 +46,13 @@ func TestHandlePing(t *testing.T) {
if pong.TS != expectedTS {
t.Errorf("Expected timestamp %d, got %d", expectedTS, pong.TS)
}
if env.LastPong().IsZero() {
t.Fatalf("expected LastPong to be updated on ping")
}
if time.Since(env.LastPong()) > 5*time.Second {
t.Fatalf("expected LastPong to be recent, got %s", env.LastPong())
}
}
func TestHandleCommand_Ping(t *testing.T) {