MCPcopy Create free account
hub / github.com/daodst/chat / TestGetAuthChainMultiple

Function TestGetAuthChainMultiple

roomserver/internal/query/query_test.go:126–157  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestGetAuthChainMultiple(t *testing.T) {
127 db := createEventDB()
128
129 err := db.addFakeEvents(map[string][]string{
130 "a": {},
131 "b": {"a"},
132 "c": {"a", "b"},
133 "d": {"b", "c"},
134 "e": {"a", "d"},
135 "f": {"a", "b", "c"},
136 })
137
138 if err != nil {
139 t.Fatalf("Failed to add events to db: %v", err)
140 }
141
142 result, err := GetAuthChain(context.TODO(), db.EventsFromIDs, []string{"e", "f"})
143 if err != nil {
144 t.Fatalf("getAuthChain failed: %v", err)
145 }
146
147 var returnedIDs []string
148 for _, event := range result {
149 returnedIDs = append(returnedIDs, event.EventID())
150 }
151
152 expectedIDs := []string{"a", "b", "c", "d", "e", "f"}
153
154 if !test.UnsortedStringSliceEqual(expectedIDs, returnedIDs) {
155 t.Fatalf("returnedIDs got '%v', expected '%v'", returnedIDs, expectedIDs)
156 }
157}

Callers

nothing calls this directly

Calls 3

createEventDBFunction · 0.85
GetAuthChainFunction · 0.85
addFakeEventsMethod · 0.80

Tested by

no test coverage detected