Check a ledger operation against the types its binding carries, refusing a ledger bound with none (issue 1966 T2)

This commit is contained in:
2026-11-03 15:15:58 +01:00
parent fadc73f73b
commit 5a9e997349
5 changed files with 25 additions and 45 deletions
@@ -78,10 +78,17 @@ func TestTheLedgerKeepsItsPromisesOnTheBus(t *testing.T) {
t.Fatal(err)
}
}
types := []catalogue.LedgerType{{Name: "decision", Schema: map[string]catalogue.LedgerField{"title": {Type: "string"}},
Operations: []catalogue.LedgerOperation{
{Name: "title", Effect: catalogue.EffectSetFields, Fields: []string{"title"}, Author: true},
{Name: "note", Effect: catalogue.EffectAppend, Into: "notes", Fields: []string{"says"}},
},
Indexes: []catalogue.LedgerIndex{{Name: "by-title", On: []string{"title"}}}}}
binding := membership.BusBinding{Local: "records", Storage: catalogue.StorageLedger, Template: catalogue.TemplateLedger,
History: "LEDGER_m_records", Subject: "mesh.ledger.m.records", State: "m_records",
Indexes: map[string]string{"by-title": "m_records_by_title"}, Snapshot: "mesh.ledger-snapshot.m.records"}
mem := mt.MembershipOf("m", "anchor", false, nil)
binding.Types = types
mem.Bindings = []membership.BusBinding{binding}
mesh.Issue(t, mem)
conn := connect(t, "node-tools", "anchor")
@@ -92,14 +99,7 @@ func TestTheLedgerKeepsItsPromisesOnTheBus(t *testing.T) {
}
return nil
})
types := []catalogue.LedgerType{{Name: "decision", Schema: map[string]catalogue.LedgerField{"title": {Type: "string"}},
Operations: []catalogue.LedgerOperation{
{Name: "title", Effect: catalogue.EffectSetFields, Fields: []string{"title"}, Author: true},
{Name: "note", Effect: catalogue.EffectAppend, Into: "notes", Fields: []string{"says"}},
},
Indexes: []catalogue.LedgerIndex{{Name: "by-title", On: []string{"title"}}}}}
all := &consumers{conn: conn, logf: t.Logf, of: map[string]*moduleEvents{}}
WithLedgerTypes(func(string, string) ([]catalogue.LedgerType, error) { return types, nil })(all)
WithLedgerWriters(func(string) (*bus.Conn, error) { return conn, nil })(all)
m := all.forModule("m").(*moduleBus)