Add Fleet Torrent erasure extension with shard DHT and gossip.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Content-addressed shard DHT on seeder agents with subnet_primary_seeder election, cross-subnet fleet_torrent_gossip, BGP swarm magnets, C2 torrent manifest, and k-of-n peer fetch with C2 fallback.
This commit is contained in:
35
agent/client/fleet_torrent_gossip_test.go
Normal file
35
agent/client/fleet_torrent_gossip_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user