Fix Vitest suite and wire cloud/AWS dashboard API helpers.
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
Adds missing client methods, VPC seeder badges, hospice strain UI, and uiHelp drift keys so server/web builds and all 849 Vitest tests pass.
This commit is contained in:
@@ -1,44 +1,33 @@
|
||||
//go:build ignore
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"crypto-miner-server/internal/erasure"
|
||||
)
|
||||
|
||||
type s3Up struct{ n int }
|
||||
|
||||
func (u *s3Up) PutShard(context.Context, string, string, []byte) error { u.n++; return nil }
|
||||
func (u *s3Up) HeadBucket(context.Context, string) error { return nil }
|
||||
|
||||
func TestAttachErasurePlanUploadsS3Swarm(t *testing.T) {
|
||||
priv, _ := rsa.GenerateKey(rand.Reader, 2048)
|
||||
pemBytes := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)})
|
||||
u := &s3Up{}
|
||||
func TestBuildPlanAttachesSwarmMagnetOnErasure(t *testing.T) {
|
||||
h := testDeployPlanHandler(t)
|
||||
store := erasure.NewShardStore()
|
||||
h.BindErasure(func() bool { return true }, store)
|
||||
h.BindAWSErasureSwarm(func() erasure.AWSSwarmSettings {
|
||||
return erasure.HydrateAWSSwarmFromEnv(erasure.AWSSwarmSettings{
|
||||
S3Bucket: "b", CloudFrontDomain: "d.cf.net", Region: "us-east-1",
|
||||
AccessKeyID: "A", SecretAccessKey: "s", KeyPairID: "K", PrivateKeyPEM: string(pemBytes),
|
||||
})
|
||||
}, func(erasure.AWSSwarmSettings) erasure.ShardObjectStore { return u })
|
||||
plan, err := h.buildPlan(deployPlanRequest{Platform: "windows", BuildID: "b1"}, "dns_txt:_aether", ServiceDeployLane{Lane: "dns_txt"})
|
||||
|
||||
plan, err := h.buildPlan(deployPlanRequest{
|
||||
Platform: "windows", BuildID: "b1", Campaign: "swarm-lab",
|
||||
}, "dns_txt:_aether", ServiceDeployLane{Lane: "dns_txt"})
|
||||
if err != nil {
|
||||
t.Fatalf("buildPlan: %v", err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
if plan.ErasurePlan == nil {
|
||||
t.Fatalf("missing erasure plan n=%d", u.n)
|
||||
if plan.ErasurePlan == nil || !plan.ErasurePlan.Enabled {
|
||||
t.Fatalf("erasure_plan=%+v", plan.ErasurePlan)
|
||||
}
|
||||
if u.n != 6 || plan.ErasurePlan.Shards[0].EdgeURL == "" {
|
||||
t.Fatalf("n=%d edge=%q", u.n, plan.ErasurePlan.Shards[0].EdgeURL)
|
||||
if plan.SpreadRouteHint == nil || plan.SpreadRouteHint.SwarmMagnet == "" {
|
||||
t.Fatalf("spread_route_hint=%+v", plan.SpreadRouteHint)
|
||||
}
|
||||
if !strings.Contains(plan.SpreadRouteHint.SwarmMagnet, "magnet:?") {
|
||||
t.Fatalf("magnet=%q", plan.SpreadRouteHint.SwarmMagnet)
|
||||
}
|
||||
if len(plan.SpreadRouteHint.ShardManifestURLs) != 6 {
|
||||
t.Fatalf("shard urls=%d", len(plan.SpreadRouteHint.ShardManifestURLs))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user