mirror of
https://github.com/1f349/dendrite.git
synced 2024-12-23 08:44:11 +00:00
6de29c1cd2
* Fix flakey sytest 'Local device key changes get to remote servers' * Debug logs * Remove internal/test and use /test only Remove a lot of ancient code too. * Use FederationRoomserverAPI in more places * Use more interfaces in federationapi; begin adding regression test * Linting * Add regression test * Unbreak tests * ALL THE LOGS * Fix a race condition which could cause events to not be sent to servers If a new room event which rewrites state arrives, we remove all joined hosts then re-calculate them. This wasn't done in a transaction so for a brief period we would have no joined hosts. During this interim, key change events which arrive would not be sent to destination servers. This would sporadically fail on sytest. * Unbreak new tests * Linting
36 lines
909 B
Go
36 lines
909 B
Go
package testrig
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/matrix-org/dendrite/roomserver/api"
|
|
"github.com/matrix-org/dendrite/setup/base"
|
|
"github.com/matrix-org/dendrite/setup/jetstream"
|
|
"github.com/nats-io/nats.go"
|
|
)
|
|
|
|
func MustPublishMsgs(t *testing.T, jsctx nats.JetStreamContext, msgs ...*nats.Msg) {
|
|
t.Helper()
|
|
for _, msg := range msgs {
|
|
if _, err := jsctx.PublishMsg(msg); err != nil {
|
|
t.Fatalf("MustPublishMsgs: failed to publish message: %s", err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func NewOutputEventMsg(t *testing.T, base *base.BaseDendrite, roomID string, update api.OutputEvent) *nats.Msg {
|
|
t.Helper()
|
|
msg := &nats.Msg{
|
|
Subject: base.Cfg.Global.JetStream.Prefixed(jetstream.OutputRoomEvent),
|
|
Header: nats.Header{},
|
|
}
|
|
msg.Header.Set(jetstream.RoomID, roomID)
|
|
var err error
|
|
msg.Data, err = json.Marshal(update)
|
|
if err != nil {
|
|
t.Fatalf("failed to marshal update: %s", err)
|
|
}
|
|
return msg
|
|
}
|