Mark the delivery gate's asks, merges, owed and source readable, as mesh-delivery's parts read them (issue 1790)
This commit is contained in:
@@ -4,9 +4,9 @@ import "git.novox.be/novox/mesh-sdk/go/announce"
|
||||
|
||||
// Kept is every state this module keeps on the bus and whether other modules may read it (novox/hq ADR 0495 clause 2;
|
||||
// issue 1790): the module says it itself, from its code, before it serves, and a reader is granted what it said
|
||||
// (clause 3). A state is readable when another module's manifest reads it. keeps_test.go holds the list to the
|
||||
// (clause 3). A state is readable when another module's manifest reads it (keeps_test.go names the readers). keeps_test.go holds the list to the
|
||||
// manifest's `state`, and keeps_integration_test.go that the module announces it on a bus.
|
||||
var Kept = []announce.State{{Name: "asks"}, {Name: "deliveries"}, {Name: "groups"}, {Name: "merges"}, {Name: "owed"}, {Name: "pulls"}, {Name: "source"}}
|
||||
var Kept = []announce.State{{Name: "asks", Readable: true}, {Name: "deliveries"}, {Name: "groups"}, {Name: "merges", Readable: true}, {Name: "owed", Readable: true}, {Name: "pulls"}, {Name: "source", Readable: true}}
|
||||
|
||||
// announceKept says Kept through keeps, which is stdio.Keeps.
|
||||
func announceKept(keeps func(...announce.State) error) error { return keeps(Kept...) }
|
||||
|
||||
@@ -8,6 +8,16 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// readers is the gate's own declaration of who reads its states (ADR 0495 clause 3: a read is granted only when the owner
|
||||
// announced the state readable), kept here and not read from other repositories' manifests (clause 1). Each line names
|
||||
// the modules of mesh-delivery whose manifest reads the state, as of R4e.
|
||||
var readers = map[string][]string{
|
||||
"asks": {"mesh-delivery-teller", "mesh-delivery-view"},
|
||||
"merges": {"mesh-delivery-forge-bridge"},
|
||||
"owed": {"mesh-delivery-forge-bridge"},
|
||||
"source": {"mesh-delivery-indexer", "mesh-delivery-checker"},
|
||||
}
|
||||
|
||||
// 1790/S: the states the module announces are the states its manifest declares, no more, no fewer, and the readable
|
||||
// ones are the states other modules' manifests read.
|
||||
func TestTheStatesTheModuleAnnouncesAreTheStatesItsManifestDeclares(t *testing.T) {
|
||||
@@ -42,10 +52,9 @@ func TestTheStatesTheModuleAnnouncesAreTheStatesItsManifestDeclares(t *testing.T
|
||||
if !slices.Equal(declared, announced) {
|
||||
t.Errorf("announces %v, the manifest declares %v", announced, declared)
|
||||
}
|
||||
want := map[string]bool{}
|
||||
for _, s := range Kept {
|
||||
if s.Readable != want[s.Name] {
|
||||
t.Errorf("state %s readable = %v, other modules' manifests read it: %v", s.Name, s.Readable, want[s.Name])
|
||||
if want := len(readers[s.Name]) > 0; s.Readable != want {
|
||||
t.Errorf("state %s readable = %v, but its readers are %v", s.Name, s.Readable, readers[s.Name])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user