Return the lines the composition found on the way (a node not counted as on the network) in Rendered.Said and Declared.Said (review round 1, finding 6). The test failed first; the suite is 1258 tests in 1.05 s

This commit is contained in:
2026-10-20 07:03:36 +00:00
parent 3eadff23eb
commit 28d4b9eb0d
4 changed files with 48 additions and 0 deletions
+11
View File
@@ -3,6 +3,7 @@ package compose
import (
"errors"
"fmt"
"slices"
"sort"
"strconv"
"strings"
@@ -50,6 +51,16 @@ func (c *composer) suffix() string {
// internalName is a node's name inside the mesh.
func (c *composer) internalName(node string) string { return node + "." + c.suffix() }
// saidBeside is the lines already said and then every line the composer kept, once each, in the order they were found.
func (c *composer) saidBeside(lines []string) []string {
for _, l := range c.said {
if !slices.Contains(lines, l) {
lines = append(lines, l)
}
}
return lines
}
// overlayRange is the range the mesh allocates node addresses from: the adopted tunnel's first (novox/hq ADR 0105),
// then the range genesis was told, then the default.
func (c *composer) overlayRange() string {
+1
View File
@@ -227,6 +227,7 @@ func (c *composer) declaration(nodeName string, mode Mode) (Declared, error) {
for _, l := range left {
out.Said = append(out.Said, l.String())
}
out.Said = c.saidBeside(out.Said)
return out, nil
}
+34
View File
@@ -382,3 +382,37 @@ func TestTheRestOfTheMeshReadsEachOtherNodesKeptBuild(t *testing.T) {
t.Errorf("a node keeping a build that offers nothing still offers: %v %v", providers(w, "s3-bucket"), err)
}
}
// Round 1, finding 6: the nodes the composition did not count as on the network are returned, said, not lost.
func TestANodeNotCountedAsOnTheNetworkIsSaidInTheResult(t *testing.T) {
in := aMesh(t)
in.Catalogue["rival-one"] = catalogue.Manifest{Module: "rival-one", Version: "1", Claims: []catalogue.Claim{{Name: "the-seat", Scope: catalogue.ScopeNode}}}
in.Catalogue["rival-two"] = catalogue.Manifest{Module: "rival-two", Version: "1", Claims: []catalogue.Claim{{Name: "the-seat", Scope: catalogue.ScopeNode}}}
laptop := nodeOf(t, &in, "laptop")
laptop.Assigned = append(laptop.Assigned, "rival-one", "rival-two")
said := func(lines []string) bool {
for _, l := range lines {
if strings.HasPrefix(l, "laptop is not counted as on the network") {
return true
}
}
return false
}
got, err := Render(in, "anchor", Foreseeing)
if err != nil || !said(got.Said) {
t.Errorf("rendered: %v %v", got.Said, err)
}
d, _, err := Compose(in, "anchor")
if err != nil || !said(d.Said) {
t.Errorf("declared: %v %v", d.Said, err)
}
n := 0
for _, l := range d.Said {
if strings.HasPrefix(l, "laptop is not counted") {
n++
}
}
if n != 1 {
t.Errorf("said %d times: %v", n, d.Said)
}
}
+2
View File
@@ -122,5 +122,7 @@ func (c *composer) render(nodeName string, mode Mode) (Rendered, error) {
}
r.BusMembership = c.in.BusMemberships[nodeName]
out.Rendering = r
// And what the composition found on the way, which the controller writes to its log: a machine not counted as on the network.
out.Said = c.saidBeside(out.Said)
return out, nil
}