Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Unified expandable panels with mermaid flows, ZIP export, connection tests, and Playwright smoke coverage.
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package client
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"crypto-miner-agent/config"
|
|
"crypto-miner-agent/deploy"
|
|
)
|
|
|
|
func TestHandleFleetTorrentGossipMergesDHT(t *testing.T) {
|
|
c := NewAgentClient(config.RuntimeConfig{})
|
|
payload, _ := json.Marshal(map[string]interface{}{
|
|
"records": []deploy.FleetGossipRecord{{
|
|
Kind: deploy.FleetGossipHaveShard, AgentID: "peer", Token: "tok",
|
|
ShardIndex: 1, ShardHash: "deadbeef", FetchURL: "http://peer/shard/1",
|
|
}},
|
|
})
|
|
c.handleFleetTorrentGossip(payload)
|
|
peers := deploy.FleetShardDHTSnapshot().PeersForShard("tok", 1, "10.0.0", "")
|
|
if len(peers) != 1 || peers[0].AgentID != "peer" {
|
|
t.Fatalf("peers=%+v", peers)
|
|
}
|
|
}
|
|
|
|
func TestApplyAuthFleetTorrentPrimarySeeder(t *testing.T) {
|
|
c := NewAgentClient(config.RuntimeConfig{AgentID: "primary-1"})
|
|
c.applyAuthFleetTorrent(AuthResponse{
|
|
FleetTorrentEnabled: true,
|
|
SubnetPrimarySeeder: "primary-1",
|
|
})
|
|
if !c.fleetTorrentEnabledSnapshot() || !c.subnetPrimarySeederSnapshot() {
|
|
t.Fatal("expected fleet torrent primary seeder")
|
|
}
|
|
}
|