49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"crypto-miner-agent/config"
|
|
)
|
|
|
|
func TestMiningDiagnosticsReadyRequiresC2(t *testing.T) {
|
|
d := MiningDiagnostics{C2Connected: false}
|
|
if MiningDiagnosticsReady(d) {
|
|
t.Fatal("expected false without C2")
|
|
}
|
|
d.C2Connected = true
|
|
if !MiningDiagnosticsReady(d) {
|
|
t.Fatal("expected true with C2 and no hard blockers")
|
|
}
|
|
}
|
|
|
|
func TestMiningDiagnosticsReadyRejectsExhausted(t *testing.T) {
|
|
d := MiningDiagnostics{C2Connected: true, ChainExhausted: true}
|
|
if MiningDiagnosticsReady(d) {
|
|
t.Fatal("expected false when chain exhausted")
|
|
}
|
|
}
|
|
|
|
func TestMiningDiagnosticsReadyRejectsHostDisabled(t *testing.T) {
|
|
d := MiningDiagnostics{
|
|
C2Connected: true,
|
|
HostMiningDisabled: true,
|
|
ContainerRunning: false,
|
|
}
|
|
if MiningDiagnosticsReady(d) {
|
|
t.Fatal("expected false when host mining disabled without container")
|
|
}
|
|
}
|
|
|
|
func TestMiningDiagnosticsReadyIgnoresTransientBlockers(t *testing.T) {
|
|
c := testDiagnosticsClient(t, config.RuntimeConfig{})
|
|
d := MiningDiagnostics{
|
|
C2Connected: true,
|
|
LikelyBlockers: []string{"C2 connected but no mining job delivered"},
|
|
}
|
|
if !MiningDiagnosticsReady(d) {
|
|
t.Fatalf("transient blockers should not block ready state: %v", d.LikelyBlockers)
|
|
}
|
|
_ = c
|
|
}
|