@@ -919,6 +919,101 @@ func TestImportHistoricalMessages(t *testing.T) {
919919				})
920920			})
921921
922+ 			t .Run ("asdf: why current_state empty when federated re-join" , func (t  * testing.T ) {
923+ 				t .Parallel ()
924+ 
925+ 				roomID  :=  as .CreateRoom (t , createPublicRoomOpts )
926+ 				alice .JoinRoom (t , roomID , nil )
927+ 
928+ 				// eventIDsBefore := createMessagesInRoom(t, alice, roomID, 1, "eventIDsBefore") 
929+ 				createMessagesInRoom (t , alice , roomID , 1 , "eventIDsBefore" )
930+ 				// eventIdBefore := eventIDsBefore[0] 
931+ 				// timeAfterEventBefore := time.Now() 
932+ 
933+ 				// createMessagesInRoom(t, alice, roomID, 3, "eventIDsAfter") 
934+ 
935+ 				// Join the room from a remote homeserver before the historical messages were sent 
936+ 				remoteCharlie .JoinRoom (t , roomID , []string {"hs1" })
937+ 
938+ 				// Make sure all of the events have been backfilled for the remote user 
939+ 				// before we leave the room 
940+ 				// fetchUntilMessagesResponseHas(t, remoteCharlie, roomID, func(ev gjson.Result) bool { 
941+ 				// 	if ev.Get("event_id").Str == eventIdBefore { 
942+ 				// 		return true 
943+ 				// 	} 
944+ 
945+ 				// 	return false 
946+ 				// }) 
947+ 
948+ 				// Leave before the historical messages are imported 
949+ 				remoteCharlie .LeaveRoom (t , roomID )
950+ 
951+ 				// batchSendRes := batchSendHistoricalMessages( 
952+ 				// 	t, 
953+ 				// 	as, 
954+ 				// 	roomID, 
955+ 				// 	eventIdBefore, 
956+ 				// 	"", 
957+ 				// 	createJoinStateEventsForBatchSendRequest([]string{virtualUserID}, timeAfterEventBefore), 
958+ 				// 	createMessageEventsForBatchSendRequest([]string{virtualUserID}, timeAfterEventBefore, 2), 
959+ 				// 	// Status 
960+ 				// 	200, 
961+ 				// ) 
962+ 				// batchSendResBody := client.ParseJSON(t, batchSendRes) 
963+ 				// // historicalEventIDs := client.GetJSONFieldStringArray(t, batchSendResBody, "event_ids") 
964+ 				// baseInsertionEventID := client.GetJSONFieldStr(t, batchSendResBody, "base_insertion_event_id") 
965+ 
966+ 				// Send the marker event which lets remote homeservers know there are 
967+ 				// some historical messages back at the given insertion event. 
968+ 				// sendMarkerAndEnsureBackfilled(t, as, alice, roomID, baseInsertionEventID) 
969+ 				// sendMarkerAndEnsureBackfilled(t, as, alice, roomID, eventIdBefore) 
970+ 				// fetchUntilMessagesResponseHas(t, alice, roomID, func(ev gjson.Result) bool { 
971+ 				// 	if ev.Get("event_id").Str == eventIdBefore { 
972+ 				// 		return true 
973+ 				// 	} 
974+ 
975+ 				// 	return false 
976+ 				// }) 
977+ 
978+ 				markerEvent  :=  b.Event {
979+ 					Type : markerEventType ,
980+ 					Content : map [string ]interface {}{
981+ 						markerInsertionContentField : "foo" ,
982+ 					},
983+ 				}
984+ 				// We can't use as.SendEventSynced(...) because application services can't use the /sync API 
985+ 				// markerSendRes := as.MustDoFunc(t, "PUT", []string{"_matrix", "client", "r0", "rooms", roomID, "state", markerEvent.Type}, client.WithJSONBody(t, markerEvent.Content)) 
986+ 				as .MustDoFunc (t , "PUT" , []string {"_matrix" , "client" , "r0" , "rooms" , roomID , "state" , markerEvent .Type }, client .WithJSONBody (t , markerEvent .Content ))
987+ 				// markerSendBody := client.ParseJSON(t, markerSendRes) 
988+ 				// markerEventID := client.GetJSONFieldStr(t, markerSendBody, "event_id") 
989+ 
990+ 				// alice.MustSyncUntil(t, client.SyncReq{}, client.SyncTimelineHas(roomID, func(ev gjson.Result) bool { 
991+ 				// 	return ev.Get("event_id").Str == markerEventID 
992+ 				// })) 
993+ 
994+ 				// fetchUntilMessagesResponseHas(t, alice, roomID, func(ev gjson.Result) bool { 
995+ 				// 	if ev.Get("event_id").Str == eventIdBefore { 
996+ 				// 		return true 
997+ 				// 	} 
998+ 
999+ 				// 	return false 
1000+ 				// }) 
1001+ 
1002+ 				// alice.SendEventSynced(t, roomID, b.Event{ 
1003+ 				// 	Type:     "foostate", 
1004+ 				// 	StateKey: b.Ptr(""), 
1005+ 				// 	Content: map[string]interface{}{ 
1006+ 				// 		"foo": "bar", 
1007+ 				// 	}, 
1008+ 				// }) 
1009+ 
1010+ 				// Add some events after the marker so that remoteCharlie doesn't see the marker 
1011+ 				// createMessagesInRoom(t, alice, roomID, 3, "eventIDFiller") 
1012+ 
1013+ 				// Join the room from a remote homeserver after the historical messages were sent 
1014+ 				remoteCharlie .JoinRoom (t , roomID , []string {"hs1" })
1015+ 			})
1016+ 
9221017			t .Run ("Historical messages show up for remote federated homeserver even the homeserver is missing the part of the timeline where the marker was sent and it paginates before it occured" , func (t  * testing.T ) {
9231018				t .Parallel ()
9241019
@@ -973,6 +1068,11 @@ func TestImportHistoricalMessages(t *testing.T) {
9731068				// Join the room from a remote homeserver after the historical messages were sent 
9741069				remoteCharlie .JoinRoom (t , roomID , []string {"hs1" })
9751070
1071+ 				// TODO: Try wait for the remote join to complete 
1072+ 				// remoteCharlie.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "context", markerEventId}, client.WithContentType("application/json"), client.WithQueries(url.Values{ 
1073+ 				// 	"limit": []string{"0"}, 
1074+ 				// })) 
1075+ 
9761076				// Make a /context request for eventIDAfter to get pagination token before the marker event 
9771077				contextRes  :=  remoteCharlie .MustDoFunc (t , "GET" , []string {"_matrix" , "client" , "r0" , "rooms" , roomID , "context" , eventIDAfter }, client .WithContentType ("application/json" ), client .WithQueries (url.Values {
9781078					"limit" : []string {"0" },
0 commit comments