mesh/delivery merged: source.main moved to novox/mesh-networking@9be2faaf8b00
mesh/delivery-group group feat/47-G-join12 merged: every member is merged
mesh/check failed (2): mesh-delivery-checker: no published of the tagged version of go-meshconditions of me…; and 1 more | ccfdaec5ed2d on 9be2faaf8b00
The two tests G added fold into existing ones as subtests (design 47 G §626); route-proxy's provider test names a role, not a node (T5). Builds: design 47 G §626, A-306; review round 2 findings T2, T5 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
106 lines
3.6 KiB
Go
106 lines
3.6 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)
|
|
}
|
|
}
|
|
|
|
// Each provision the module offers says its credential's form, as the manifest validator requires of every offer.
|
|
func TestEveryProvisionTheModuleOffersSaysItsCredentialForm(t *testing.T) {
|
|
raw, err := json.Marshal(Manifest())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m, err := catalogue.Decode(raw)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(m.Provides) != 2 {
|
|
t.Fatalf("the module provides %+v: the network and the addresses", m.Provides)
|
|
}
|
|
for _, o := range m.Provides {
|
|
if o.Credential == nil || o.Credential.Form != "none" {
|
|
t.Errorf("%s offers credential %+v: the form is none", o.Name, o.Credential)
|
|
}
|
|
}
|
|
// Design 47 G §411, §339, §341: no artifact of this repository's manifests keeps a `series` (one version per module), and
|
|
// the generated TypeScript contract is `index.js` with its `index.d.ts`, with no source for a build of its own.
|
|
t.Run("NoArtifactKeepsASeriesAndTheTypeScriptContractIsJavaScript", func(t *testing.T) {
|
|
for _, path := range []string{"../../module.json", "../../../mesh-connectivity-contracts/module.json"} {
|
|
file, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var m struct {
|
|
Build struct {
|
|
Artifacts []map[string]any `json:"artifacts"`
|
|
} `json:"build"`
|
|
}
|
|
if err := json.Unmarshal(file, &m); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, a := range m.Build.Artifacts {
|
|
if _, ok := a["series"]; ok {
|
|
t.Errorf("%s: the artifact %v keeps a series, which the manifest validator refuses (§411)", path, a["name"])
|
|
}
|
|
}
|
|
}
|
|
dir := "../../../mesh-connectivity-contracts/ts/seats/theprivatenetwork/"
|
|
for file, want := range map[string]bool{"index.js": true, "index.d.ts": true, "src/index.ts": false, "tsconfig.json": false} {
|
|
if _, err := os.Stat(dir + file); (err == nil) != want {
|
|
t.Errorf("%s: present %v, want %v (§341)", file, err == nil, want)
|
|
}
|
|
}
|
|
})
|
|
}
|