@@ -9,8 +9,10 @@ package tests
99import (
1010 "net/url"
1111 "testing"
12+ "time"
1213
1314 "github.com/matrix-org/complement/internal/b"
15+ "github.com/matrix-org/complement/internal/client"
1416 "github.com/matrix-org/complement/internal/must"
1517 "github.com/sirupsen/logrus"
1618 "github.com/tidwall/gjson"
@@ -33,6 +35,13 @@ func TestBackfillingHistory(t *testing.T) {
3335 "body" : "Message A" ,
3436 },
3537 })
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+
3645 // eventB
3746 alice .SendEventSynced (t , roomID , b.Event {
3847 Type : "m.room.message" ,
@@ -56,6 +65,7 @@ func TestBackfillingHistory(t *testing.T) {
5665 PrevEvents : []string {
5766 eventA ,
5867 },
68+ OriginServerTS : insertOriginServerTs ,
5969 Content : map [string ]interface {}{
6070 "msgtype" : "m.text" ,
6171 "body" : "Message 1" ,
@@ -68,6 +78,7 @@ func TestBackfillingHistory(t *testing.T) {
6878 PrevEvents : []string {
6979 event1 ,
7080 },
81+ OriginServerTS : insertOriginServerTs + 1 ,
7182 Content : map [string ]interface {}{
7283 "msgtype" : "m.text" ,
7384 "body" : "Message 2" ,
@@ -80,6 +91,7 @@ func TestBackfillingHistory(t *testing.T) {
8091 PrevEvents : []string {
8192 event2 ,
8293 },
94+ OriginServerTS : insertOriginServerTs + 2 ,
8395 Content : map [string ]interface {}{
8496 "msgtype" : "m.text" ,
8597 "body" : "Message 3" ,
@@ -92,8 +104,11 @@ func TestBackfillingHistory(t *testing.T) {
92104 })
93105
94106 t .Logf ("aweawfeefwaweafeafw" )
107+ body := client .ParseJSON (t , res )
95108 logrus .WithFields (logrus.Fields {
96- "res" : res ,
109+ "insertOriginServerTs" : insertOriginServerTs ,
110+ "res" : res ,
111+ "body" : string (body ),
97112 }).Error ("messages res" )
98113
99114 t .Run ("parallel" , func (t * testing.T ) {
0 commit comments