From 0875ba2073383d190b522954b1758a5ec372f796 Mon Sep 17 00:00:00 2001 From: Devon Hudson Date: Fri, 16 Dec 2022 11:05:13 -0700 Subject: [PATCH] Setup default relayapi config --- relayapi/relayapi_test.go | 45 +++++++++++++++++++++++++++++++++++++++ setup/config/config.go | 1 + 2 files changed, 46 insertions(+) create mode 100644 relayapi/relayapi_test.go diff --git a/relayapi/relayapi_test.go b/relayapi/relayapi_test.go new file mode 100644 index 000000000..aa5f3c6ab --- /dev/null +++ b/relayapi/relayapi_test.go @@ -0,0 +1,45 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package relayapi_test + +import ( + "testing" + + "github.com/matrix-org/dendrite/relayapi" + "github.com/matrix-org/dendrite/setup/jetstream" + "github.com/matrix-org/dendrite/test" + "github.com/matrix-org/dendrite/test/testrig" + "github.com/stretchr/testify/assert" +) + +func TestCreateNewRelayInternalAPI(t *testing.T) { + test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { + base, close := testrig.CreateBaseDendrite(t, dbType) + base.Cfg.FederationAPI.PreferDirectFetch = true + base.Cfg.FederationAPI.KeyPerspectives = nil + defer close() + jsctx, _ := base.NATS.Prepare(base.ProcessContext, &base.Cfg.Global.JetStream) + defer jetstream.DeleteAllStreams(jsctx, &base.Cfg.Global.JetStream) + + relayAPI := relayapi.NewRelayInternalAPI( + base, + nil, + nil, + nil, + nil, + ) + assert.NotNil(t, relayAPI) + }) +} diff --git a/setup/config/config.go b/setup/config/config.go index a2d1d3def..db1b12fd3 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -348,6 +348,7 @@ func (c *Dendrite) Defaults(opts DefaultOpts) { c.SyncAPI.Defaults(opts) c.UserAPI.Defaults(opts) c.AppServiceAPI.Defaults(opts) + c.RelayAPI.Defaults(opts) c.MSCs.Defaults(opts) c.Wiring() }