mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 12:52:24 +03:00
Move json errors over to gmsl (#3080)
This commit is contained in:
parent
a49c9f01e2
commit
0489d16f95
109 changed files with 808 additions and 1217 deletions
|
@ -66,9 +66,8 @@ var (
|
|||
|
||||
type FakeRsAPI struct {
|
||||
rsAPI.RoomserverInternalAPI
|
||||
shouldFailQuery bool
|
||||
bannedFromRoom bool
|
||||
shouldEventsFail bool
|
||||
shouldFailQuery bool
|
||||
bannedFromRoom bool
|
||||
}
|
||||
|
||||
func (r *FakeRsAPI) QueryRoomVersionForRoom(
|
||||
|
@ -98,11 +97,7 @@ func (r *FakeRsAPI) InputRoomEvents(
|
|||
ctx context.Context,
|
||||
req *rsAPI.InputRoomEventsRequest,
|
||||
res *rsAPI.InputRoomEventsResponse,
|
||||
) error {
|
||||
if r.shouldEventsFail {
|
||||
return fmt.Errorf("Failure")
|
||||
}
|
||||
return nil
|
||||
) {
|
||||
}
|
||||
|
||||
func TestEmptyTransactionRequest(t *testing.T) {
|
||||
|
@ -184,18 +179,6 @@ func TestProcessTransactionRequestPDUInvalidSignature(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestProcessTransactionRequestPDUSendFail(t *testing.T) {
|
||||
keyRing := &test.NopJSONVerifier{}
|
||||
txn := NewTxnReq(&FakeRsAPI{shouldEventsFail: true}, nil, "ourserver", keyRing, nil, nil, false, []json.RawMessage{testEvent}, []gomatrixserverlib.EDU{}, "", "", "")
|
||||
txnRes, jsonRes := txn.ProcessTransaction(context.Background())
|
||||
|
||||
assert.Nil(t, jsonRes)
|
||||
assert.Equal(t, 1, len(txnRes.PDUs))
|
||||
for _, result := range txnRes.PDUs {
|
||||
assert.NotEmpty(t, result.Error)
|
||||
}
|
||||
}
|
||||
|
||||
func createTransactionWithEDU(ctx *process.ProcessContext, edus []gomatrixserverlib.EDU) (TxnReq, nats.JetStreamContext, *config.Dendrite) {
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults(config.DefaultOpts{
|
||||
|
@ -659,12 +642,11 @@ func (t *testRoomserverAPI) InputRoomEvents(
|
|||
ctx context.Context,
|
||||
request *rsAPI.InputRoomEventsRequest,
|
||||
response *rsAPI.InputRoomEventsResponse,
|
||||
) error {
|
||||
) {
|
||||
t.inputRoomEvents = append(t.inputRoomEvents, request.InputRoomEvents...)
|
||||
for _, ire := range request.InputRoomEvents {
|
||||
fmt.Println("InputRoomEvents: ", ire.Event.EventID())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Query the latest events and state for a room from the room server.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue