The state, events and types of the seat mesh-module-assigner say assignments; the legacy node key form is gone from the reads; the dead seat-verb list of the retired name is deleted. The placement guard and the placed-file sense stay. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
73 lines
2.6 KiB
Go
73 lines
2.6 KiB
Go
package buckets
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"encoding/json"
|
|
"git.novox.be/novox/mesh-sdk/go/keys"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// The engine's own states are named <module>_<state> by the manifest; a constant that drifts from it reads and writes a
|
|
// bucket nobody else knows (ADR 0634 §1, finding F4: the holder's name is kept in code and held to the manifest by this row).
|
|
func TestTheOwnStatesAreTheManifestsStates(t *testing.T) {
|
|
raw, err := os.ReadFile("../../module.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var m struct {
|
|
Module string `json:"module"`
|
|
State []struct {
|
|
Name string `json:"name"`
|
|
} `json:"state"`
|
|
}
|
|
if err := json.Unmarshal(raw, &m); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
declared := map[string]bool{}
|
|
for _, s := range m.State {
|
|
declared[m.Module+"_"+s.Name] = true
|
|
}
|
|
for name, bucket := range map[string]string{"data": Data, "health": Health} {
|
|
if !declared[bucket] {
|
|
t.Errorf("the bucket %s for the state %s is not one the manifest of %s declares (%v)", bucket, name, m.Module, declared)
|
|
}
|
|
}
|
|
}
|
|
|
|
// A group's candidate key is its name as a key part: a branch with a slash keeps it, a dot is escaped, and an empty group does not.
|
|
func TestACandidateKeyEscapesTheGroup(t *testing.T) {
|
|
for _, group := range []string{"mesh-sdk#7", "fix/940-no-retire", "fix/1.2"} {
|
|
key, err := CandidateKey(group)
|
|
if err != nil {
|
|
t.Fatalf("%s: %v", group, err)
|
|
}
|
|
if strings.Contains(key, ".") {
|
|
t.Errorf("the key %q of %q holds a dot", key, group)
|
|
}
|
|
if back, err := keys.UnescapeName(key); err != nil || back != group {
|
|
t.Errorf("%q came back as %q (%v)", group, back, err)
|
|
}
|
|
}
|
|
if _, err := CandidateKey(""); err == nil {
|
|
t.Error("a key was made for no group")
|
|
}
|
|
}
|
|
|
|
// The holders' buckets are the names the grants part grants and the holders' manifests declare: no client carries a
|
|
// holder (ADR 0625 §4), so these rows are the one place the node-engine's code says them.
|
|
func TestTheHoldersBucketsAreTheirStatesBuckets(t *testing.T) {
|
|
for name, c := range map[string][2]string{
|
|
"Assignments": {Assignments, "mesh-delivery-assigner_assignments"}, "ProposalCandidates": {ProposalCandidates, "mesh-delivery-assigner_candidates"},
|
|
"Wants": {Wants, "mesh-delivery-assigner_wants"}, "Modules": {Modules, "mesh-delivery-indexer_modules"},
|
|
"Manifests": {Manifests, "mesh-delivery-indexer_manifests"}, "Verdicts": {Verdicts, "mesh-delivery-indexer_verdicts"},
|
|
"Candidates": {Candidates, "mesh-delivery-indexer_candidates"}, "Provisions": {Provisions, "mesh-provisioner_provisions"},
|
|
"ProvisionsRead": {ProvisionsRead, "mesh-provisioner.provisions"},
|
|
} {
|
|
if c[0] != c[1] {
|
|
t.Errorf("%s = %q, want %q", name, c[0], c[1])
|
|
}
|
|
}
|
|
}
|