Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package atlas
|
|
|
|
import "testing"
|
|
|
|
func TestSubnetPrefixIPv4(t *testing.T) {
|
|
if got := SubnetPrefix("192.168.1.42"); got != "192.168.1" {
|
|
t.Fatalf("SubnetPrefix = %q", got)
|
|
}
|
|
if got := SubnetPrefix("192.168.1.42:12345"); got != "192.168.1" {
|
|
t.Fatalf("SubnetPrefix host:port = %q", got)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeGossipHints(t *testing.T) {
|
|
hints := NormalizeGossipHints([]GossipHint{
|
|
{Tier: " docker ", Condition: "no_docker", Reason: "blocked"},
|
|
{Tier: "", Condition: "x"},
|
|
{Tier: "wsl", Condition: "defender_on"},
|
|
})
|
|
if len(hints) != 2 {
|
|
t.Fatalf("want 2 hints, got %+v", hints)
|
|
}
|
|
if hints[0].Tier != "docker" || hints[0].Reason != "blocked" {
|
|
t.Fatalf("first hint = %+v", hints[0])
|
|
}
|
|
if hints[1].Reason != "lan gossip" {
|
|
t.Fatalf("default reason = %q", hints[1].Reason)
|
|
}
|
|
}
|
|
|
|
func TestMergeGossipSkipsDedupes(t *testing.T) {
|
|
existing := []AtlasSkip{{Tier: "docker", Condition: "no_docker", Reason: "fleet"}}
|
|
merged := MergeGossipSkips(existing, []GossipHint{
|
|
{Tier: "docker", Condition: "no_docker", Reason: "lan"},
|
|
{Tier: "wsl", Condition: "defender_on", Reason: "lan"},
|
|
})
|
|
if len(merged) != 2 {
|
|
t.Fatalf("merged = %+v", merged)
|
|
}
|
|
if merged[1].Tier != "wsl" {
|
|
t.Fatalf("second skip = %+v", merged[1])
|
|
}
|
|
}
|