Add tests around federationapi's txnReq (#1010)

* Add necessary stubs for testing txnReq

* Add basic tests
This commit is contained in:
Kegsay 2020-05-06 14:27:02 +01:00 committed by GitHub
parent 1db5dfe4d0
commit 1294852270
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 410 additions and 2 deletions

View file

@ -103,8 +103,17 @@ type txnReq struct {
rsAPI api.RoomserverInternalAPI
producer *producers.RoomserverProducer
eduProducer *producers.EDUServerProducer
keys gomatrixserverlib.KeyRing
federation *gomatrixserverlib.FederationClient
keys gomatrixserverlib.JSONVerifier
federation txnFederationClient
}
// A subset of FederationClient functionality that txn requires. Useful for testing.
type txnFederationClient interface {
LookupState(ctx context.Context, s gomatrixserverlib.ServerName, roomID string, eventID string, roomVersion gomatrixserverlib.RoomVersion) (
res gomatrixserverlib.RespState, err error,
)
LookupStateIDs(ctx context.Context, s gomatrixserverlib.ServerName, roomID string, eventID string) (res gomatrixserverlib.RespStateIDs, err error)
GetEvent(ctx context.Context, s gomatrixserverlib.ServerName, eventID string) (res gomatrixserverlib.Transaction, err error)
}
func (t *txnReq) processTransaction() (*gomatrixserverlib.RespSend, error) {