Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Agents read vpc-id from EC2 IMDS on auth; the server scopes subnet_primary_seeder to vpc-id with /24 fallback, exposes VPC seeder badges, and documents cross-VPC gossip via peering/TGW.
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")
|
|
}
|
|
}
|