@@ -9,8 +9,10 @@ package tests
9
9
import (
10
10
"net/url"
11
11
"testing"
12
+ "time"
12
13
13
14
"github.com/matrix-org/complement/internal/b"
15
+ "github.com/matrix-org/complement/internal/client"
14
16
"github.com/matrix-org/complement/internal/must"
15
17
"github.com/sirupsen/logrus"
16
18
"github.com/tidwall/gjson"
@@ -33,6 +35,13 @@ func TestBackfillingHistory(t *testing.T) {
33
35
"body" : "Message A" ,
34
36
},
35
37
})
38
+
39
+ insertTime := time .Now ()
40
+ insertOriginServerTs := uint64 (insertTime .UnixNano () / 1000000 )
41
+
42
+ // wait 3ms to ensure that the timestamp changes enough intervals for each message we try to insert later
43
+ time .Sleep (3 * time .Millisecond )
44
+
36
45
// eventB
37
46
alice .SendEventSynced (t , roomID , b.Event {
38
47
Type : "m.room.message" ,
@@ -56,6 +65,7 @@ func TestBackfillingHistory(t *testing.T) {
56
65
PrevEvents : []string {
57
66
eventA ,
58
67
},
68
+ OriginServerTS : insertOriginServerTs ,
59
69
Content : map [string ]interface {}{
60
70
"msgtype" : "m.text" ,
61
71
"body" : "Message 1" ,
@@ -68,6 +78,7 @@ func TestBackfillingHistory(t *testing.T) {
68
78
PrevEvents : []string {
69
79
event1 ,
70
80
},
81
+ OriginServerTS : insertOriginServerTs + 1 ,
71
82
Content : map [string ]interface {}{
72
83
"msgtype" : "m.text" ,
73
84
"body" : "Message 2" ,
@@ -80,6 +91,7 @@ func TestBackfillingHistory(t *testing.T) {
80
91
PrevEvents : []string {
81
92
event2 ,
82
93
},
94
+ OriginServerTS : insertOriginServerTs + 2 ,
83
95
Content : map [string ]interface {}{
84
96
"msgtype" : "m.text" ,
85
97
"body" : "Message 3" ,
@@ -92,8 +104,11 @@ func TestBackfillingHistory(t *testing.T) {
92
104
})
93
105
94
106
t .Logf ("aweawfeefwaweafeafw" )
107
+ body := client .ParseJSON (t , res )
95
108
logrus .WithFields (logrus.Fields {
96
- "res" : res ,
109
+ "insertOriginServerTs" : insertOriginServerTs ,
110
+ "res" : res ,
111
+ "body" : string (body ),
97
112
}).Error ("messages res" )
98
113
99
114
t .Run ("parallel" , func (t * testing.T ) {
0 commit comments