@@ -13,7 +13,6 @@ import (
1313 "io/ioutil"
1414 "net/http"
1515 "net/url"
16- "strconv"
1716 "testing"
1817 "time"
1918
@@ -35,7 +34,7 @@ type event struct {
3534
3635// This is configurable because it can be nice to change it to `time.Second` while
3736// checking out the test result in a Synapse instance
38- const TimeBetweenMessages = time .Millisecond
37+ const timeBetweenMessages = time .Millisecond
3938
4039var (
4140 MSC2716_INSERTION = "org.matrix.msc2716.insertion"
@@ -85,7 +84,7 @@ func TestBackfillingHistory(t *testing.T) {
8584
8685 numHistoricalMessages := 6
8786 // wait X number of ms to ensure that the timestamp changes enough for each of the messages we try to backfill later
88- time .Sleep (time .Duration (numHistoricalMessages ) * TimeBetweenMessages )
87+ time .Sleep (time .Duration (numHistoricalMessages ) * timeBetweenMessages )
8988
9089 // Create some events after.
9190 // Fill up the buffer so we have to scrollback to the inserted history later
@@ -101,7 +100,7 @@ func TestBackfillingHistory(t *testing.T) {
101100 virtualUserID ,
102101 roomID ,
103102 eventBefore ,
104- timeAfterEventBefore .Add (TimeBetweenMessages * 3 ),
103+ timeAfterEventBefore .Add (timeBetweenMessages * 3 ),
105104 "" ,
106105 3 ,
107106 // Status
@@ -454,49 +453,9 @@ func getEventIDsFromResponseBody(t *testing.T, body []byte) (eventIDsFromRespons
454453 return eventIDsFromResponse
455454}
456455
457- var txnID int = 0
458-
459- // The transactions need to be prefixed so they don't collide with the txnID in client.go
460- var txnPrefix string = "msc2716-txn"
461-
462- func sendEvent (t * testing.T , c * client.CSAPI , virtualUserID string , roomID string , e event ) string {
463- txnID ++
464-
465- query := make (url.Values , len (e .PrevEvents ))
466- for _ , prevEvent := range e .PrevEvents {
467- query .Add ("prev_event" , prevEvent )
468- }
469-
470- if e .OriginServerTS != 0 {
471- query .Add ("ts" , strconv .FormatUint (e .OriginServerTS , 10 ))
472- }
473-
474- if virtualUserID != "" {
475- query .Add ("user_id" , virtualUserID )
476- }
477-
478- b , err := json .Marshal (e .Content )
479- if err != nil {
480- t .Fatalf ("msc2716.sendEvent failed to marshal JSON body: %s" , err )
481- }
482-
483- res := c .MustDoFunc (t , "PUT" , []string {"_matrix" , "client" , "r0" , "rooms" , roomID , "send" , e .Type , txnPrefix + strconv .Itoa (txnID )}, client .WithRawBody (b ), client .WithContentType ("application/json" ), client .WithQueries (query ))
484- body := client .ParseJSON (t , res )
485- eventID := client .GetJSONFieldStr (t , body , "event_id" )
486-
487- return eventID
488- }
489-
490456// ensureVirtualUserRegistered makes sure the user is registered for the homeserver regardless
491457// if they are already registered or not. If unable to register, fails the test
492458func ensureVirtualUserRegistered (t * testing.T , c * client.CSAPI , virtualUserLocalpart string ) {
493- // b, err := json.Marshal(map[string]interface{}{
494- // "username": virtualUserLocalpart,
495- // })
496- // if err != nil {
497- // t.Fatalf("msc2716.ensureVirtualUserRegistered failed to marshal JSON body: %s", err)
498- // }
499-
500459 res := c .DoFunc (
501460 t ,
502461 "POST" ,
@@ -553,7 +512,7 @@ func backfillBatchHistoricalMessages(
553512 // Timestamp in milliseconds
554513 insertOriginServerTs := uint64 (insertTime .UnixNano () / int64 (time .Millisecond ))
555514
556- timeBetweenMessagesMS := uint64 (TimeBetweenMessages / time .Millisecond )
515+ timeBetweenMessagesMS := uint64 (timeBetweenMessages / time .Millisecond )
557516
558517 evs := make ([]map [string ]interface {}, count )
559518 for i := 0 ; i < len (evs ); i ++ {
0 commit comments