diff --git a/cmd/roomserver-integration-tests/main.go b/cmd/roomserver-integration-tests/main.go index ea4732a6b..682fc6224 100644 --- a/cmd/roomserver-integration-tests/main.go +++ b/cmd/roomserver-integration-tests/main.go @@ -28,6 +28,7 @@ import ( "net/http" + "github.com/matrix-org/dendrite/common/caching" "github.com/matrix-org/dendrite/common/test" "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/gomatrixserverlib" @@ -253,6 +254,11 @@ func testRoomserver(input []string, wantOutput []string, checkQueries func(api.R panic(err) } + cache, err := caching.NewImmutableInMemoryLRUCache() + if err != nil { + panic(err) + } + doInput := func() { fmt.Printf("Roomserver is ready to receive input, sending %d events\n", len(input)) if err = writeToRoomServer(input, cfg.RoomServerURL()); err != nil { @@ -270,7 +276,7 @@ func testRoomserver(input []string, wantOutput []string, checkQueries func(api.R cmd.Args = []string{"dendrite-room-server", "--config", filepath.Join(dir, test.ConfigFile)} gotOutput, err := runAndReadFromTopic(cmd, cfg.RoomServerURL()+"/metrics", doInput, outputTopic, len(wantOutput), func() { - queryAPI, _ := api.NewRoomserverQueryAPIHTTP("http://"+string(cfg.Listen.RoomServer), &http.Client{Timeout: timeoutHTTP}, nil) + queryAPI, _ := api.NewRoomserverQueryAPIHTTP("http://"+string(cfg.Listen.RoomServer), &http.Client{Timeout: timeoutHTTP}, cache) checkQueries(queryAPI) }) if err != nil { diff --git a/common/caching/immutableinmemorylru.go b/common/caching/immutableinmemorylru.go index fdaff1020..3e8f4aadb 100644 --- a/common/caching/immutableinmemorylru.go +++ b/common/caching/immutableinmemorylru.go @@ -28,9 +28,6 @@ func checkForInvalidMutation(cache *lru.Cache, key string, value interface{}) { } func (c *ImmutableInMemoryLRUCache) GetRoomVersion(roomID string) (gomatrixserverlib.RoomVersion, bool) { - if c == nil { - return "", false - } val, found := c.roomVersions.Get(roomID) if found && val != nil { if roomVersion, ok := val.(gomatrixserverlib.RoomVersion); ok { @@ -41,9 +38,6 @@ func (c *ImmutableInMemoryLRUCache) GetRoomVersion(roomID string) (gomatrixserve } func (c *ImmutableInMemoryLRUCache) StoreRoomVersion(roomID string, roomVersion gomatrixserverlib.RoomVersion) { - if c == nil { - return - } checkForInvalidMutation(c.roomVersions, roomID, roomVersion) c.roomVersions.Add(roomID, roomVersion) }