The grants part grants on them, the tool runner appends and snapshots on them and the bus module creates the history over them, so the three read one contract (the lead's ruling on issue 1966 B1; ADR 0597 §8, §9).
36 lines
1.7 KiB
Go
36 lines
1.7 KiB
Go
package buscompose
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/membership"
|
|
)
|
|
|
|
// The names this package keeps for the grants part's composer (mesh-grants internal/buscompose, ADR 0593 §1) agree with
|
|
// what the runtime reads: the memberships bucket, and a log's stream and subject.
|
|
func TestTheBusNamesAgree(t *testing.T) {
|
|
if GrantsMembershipsBucket != membership.GrantsBucket {
|
|
t.Fatalf("the memberships bucket is %q here and %q in membership", GrantsMembershipsBucket, membership.GrantsBucket)
|
|
}
|
|
if MembershipKey("ace", "netcheck") != "ace.netcheck" {
|
|
t.Fatal("a membership's key is not <node>.<module>")
|
|
}
|
|
if LogStreamName("mesh-delivery-builder", "build-log") == "" || LogSubject("mesh-delivery-builder", "build-log") == "" {
|
|
t.Fatal("a log has no stream or subject")
|
|
}
|
|
// 1966/AC20: a ledger's history and snapshot subjects are one contract, which the grants part grants a ledger
|
|
// account its publish on.
|
|
if h, sn := LedgerHistorySubject("m", "records"), LedgerSnapshotSubject("m", "records"); h != "mesh.ledger.m.records.history" ||
|
|
sn != "mesh.ledger.m.records.snapshot" {
|
|
t.Fatalf("a ledger's subjects are %q and %q", h, sn)
|
|
}
|
|
// 1966/AC23: a wanted account of kind ledger for m on a names the user ledger.a.m and the own secret ledgers.
|
|
ledger := WantedAccount{User: "ledger.a.m", Kind: KindLedger, Node: "a", Module: "m", URL: "nats://10.0.0.1:4222"}
|
|
if got := (Principal{Kind: KindLedger, Node: "a", Module: "m"}).Username(); got != "ledger.a.m" {
|
|
t.Fatalf("a ledger account is named %q", got)
|
|
}
|
|
if err := ledger.Valid(); err != nil || ledger.OwnSecret() != "ledgers" {
|
|
t.Fatalf("a wanted ledger account: %v, held in %q", err, ledger.OwnSecret())
|
|
}
|
|
}
|