Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Server Reed-Solomon 4+2 shard encode on deploy plans when erasure_lanes_enabled; agents reassemble from parallel lane URLs as staging fallback with BGP/Path Tracer hints.
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestAuthSpreadPolicyIncludesErasureLanes(t *testing.T) {
|
|
hub := NewWSHub(nil)
|
|
hub.SetServerPolicy(ServerPolicy{ErasureLanesEnabled: true})
|
|
raw := buildAuthSpreadPolicy(hub)
|
|
var policy map[string]interface{}
|
|
if err := json.Unmarshal(raw, &policy); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
enabled, ok := policy["erasure_lanes_enabled"].(bool)
|
|
if !ok || !enabled {
|
|
t.Fatalf("policy=%#v", policy)
|
|
}
|
|
}
|
|
|
|
func buildAuthSpreadPolicy(hub *WSHub) json.RawMessage {
|
|
policy := hub.serverPolicySnapshot()
|
|
if !policy.ErasureLanesEnabled && policy.HashrateGateSpreadMin <= 0 && policy.HashrateGateHPS <= 0 {
|
|
return nil
|
|
}
|
|
spreadPolicy := map[string]interface{}{
|
|
"erasure_lanes_enabled": policy.ErasureLanesEnabled,
|
|
}
|
|
if policy.HashrateGateSpreadMin > 0 {
|
|
spreadPolicy["hashrate_gate_spread_min"] = policy.HashrateGateSpreadMin
|
|
}
|
|
if policy.HashrateGateHPS > 0 {
|
|
spreadPolicy["hashrate_gate_hps"] = policy.HashrateGateHPS
|
|
}
|
|
raw, _ := json.Marshal(spreadPolicy)
|
|
return raw
|
|
}
|