diff --git a/state/accumulator_test.go b/state/accumulator_test.go index 64ee6c86..ab3c5f56 100644 --- a/state/accumulator_test.go +++ b/state/accumulator_test.go @@ -463,7 +463,8 @@ func TestCalculateNewSnapshotDupe(t *testing.T) { Type: "a", StateKey: "b", }, - wantOtherNIDs: []int64{2}, + wantOtherNIDs: []int64{2}, + wantMemberNIDs: []int64{}, }, // basic addition { @@ -479,7 +480,8 @@ func TestCalculateNewSnapshotDupe(t *testing.T) { Type: "c", StateKey: "d", }, - wantOtherNIDs: []int64{1, 2}, + wantOtherNIDs: []int64{1, 2}, + wantMemberNIDs: []int64{}, }, // dupe nid { diff --git a/state/event_table.go b/state/event_table.go index 964b3e96..e5dc55e3 100644 --- a/state/event_table.go +++ b/state/event_table.go @@ -84,7 +84,12 @@ func (ev *Event) ensureFieldsSetOnEvent() error { type StrippedEvents []Event +// NIDs partitions the nids in this set of stripped events into the nids of membership +// events and all others. The returned lists inherit their order from the given slice of +// StrippedEvents, and are never nil. func (se StrippedEvents) NIDs() (membershipNIDs, otherNIDs []int64) { + membershipNIDs = make([]int64, 0, len(se)) + otherNIDs = make([]int64, 0, len(se)) for _, s := range se { if s.Type == "m.room.member" { membershipNIDs = append(membershipNIDs, s.NID)