From db2bcf0cfc12019ea87afa2b829404772a488a32 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 3 Mar 2023 17:33:43 +0100 Subject: [PATCH 1/2] Add a test which checks that the transaction ID is serialised in the event --- tests/csapi/txnid_test.go | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/csapi/txnid_test.go diff --git a/tests/csapi/txnid_test.go b/tests/csapi/txnid_test.go new file mode 100644 index 00000000..e5debcd6 --- /dev/null +++ b/tests/csapi/txnid_test.go @@ -0,0 +1,40 @@ +package csapi_tests + +import ( + "github.com/matrix-org/complement/internal/b" + "github.com/matrix-org/complement/internal/client" + "github.com/matrix-org/complement/runtime" + "github.com/tidwall/gjson" + "testing" +) + +// TestTxnInEvent checks that the transaction ID is present when getting the event from the /rooms/{roomID}/event/{eventID} endpoint. +func TestTxnInEvent(t *testing.T) { + // Dendrite implementation is broken + runtime.SkipIf(t, runtime.Dendrite) + + deployment := Deploy(t, b.BlueprintCleanHS) + defer deployment.Destroy(t) + + c := deployment.RegisterUser(t, "hs1", "alice", "password", false) + + // Create a room where we can send events. + roomID := c.CreateRoom(t, map[string]interface{}{}) + + // Let's send an event, and wait for it to appear in the timeline. + eventID := c.SendEventSynced(t, roomID, b.Event{ + Type: "m.room.message", + Content: map[string]interface{}{ + "msgtype": "m.text", + "body": "first", + }, + }) + + // The transaction ID should be present on the GET /rooms/{roomID}/event/{eventID} response. + res := c.MustDoFunc(t, "GET", []string{"_matrix", "client", "v3", "rooms", roomID, "event", eventID}) + body := client.ParseJSON(t, res) + result := gjson.ParseBytes(body) + if !result.Get("unsigned.transaction_id").Exists() { + t.Fatalf("Event did not have a 'transaction_id' on the GET /rooms/%s/event/%s response", roomID, eventID) + } +} From 423e97b2a4346dc8897946af06007885cc69a4f1 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Mon, 6 Mar 2023 17:34:40 +0100 Subject: [PATCH 2/2] Add a reference to the issue in Dendrite --- tests/csapi/txnid_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/csapi/txnid_test.go b/tests/csapi/txnid_test.go index e5debcd6..5855d4ff 100644 --- a/tests/csapi/txnid_test.go +++ b/tests/csapi/txnid_test.go @@ -11,6 +11,7 @@ import ( // TestTxnInEvent checks that the transaction ID is present when getting the event from the /rooms/{roomID}/event/{eventID} endpoint. func TestTxnInEvent(t *testing.T) { // Dendrite implementation is broken + // See https://github.com/matrix-org/dendrite/issues/3000 runtime.SkipIf(t, runtime.Dendrite) deployment := Deploy(t, b.BlueprintCleanHS)