The names and the manifest come from mesh-sdk's overlay, the peer graph, the generator and the declaration from the node-engine's internal/overlay; the value's layout is the seat's contract in mesh-connectivity-contracts. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package overlay
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
|
)
|
|
|
|
// The seat's definition is mesh-connectivity-contracts' (ADR 0636 §6); this module's manifest claims it, and the
|
|
// manifest is judged against that definition as every reader of the seat list judges it (ADR 0635 §1).
|
|
func useTheSeat(t *testing.T) {
|
|
t.Helper()
|
|
raw, err := os.ReadFile("../../../mesh-connectivity-contracts/seats/the-private-network/seat.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
def, err := seatdef.Parse(raw)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
catalogue.UseSeats(catalogue.SeatsFromDefinitions([]seatdef.Definition{def}))
|
|
}
|
|
|
|
// The private network's claim is a seat the mesh defines (novox/hq ADR 0110), and the manifest the module ships is
|
|
// the manifest the node-engine folds in: module.json says what Manifest() says, beside its build.
|
|
func TestThePrivateNetworksClaimIsASeatTheMeshDefinesAndModuleJSONSaysTheSame(t *testing.T) {
|
|
useTheSeat(t)
|
|
raw, err := json.Marshal(Manifest())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := catalogue.Decode(raw); err != nil {
|
|
t.Fatalf("%s does not decode: %v", Name, err)
|
|
}
|
|
seat, defined := catalogue.SeatNamed(TheNetwork)
|
|
if !defined || seat.Scope != catalogue.ScopeNode {
|
|
t.Fatalf("%s is not a node seat the mesh defines: %+v", TheNetwork, seat)
|
|
}
|
|
file, err := os.ReadFile("../../module.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var onDisk, composed map[string]any
|
|
if err := json.Unmarshal(file, &onDisk); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
json.Unmarshal(raw, &composed)
|
|
delete(onDisk, "build")
|
|
if !reflect.DeepEqual(onDisk, composed) {
|
|
t.Errorf("module.json beside its build is %v, Manifest() is %v", onDisk, composed)
|
|
}
|
|
}
|