@@ -198,47 +198,43 @@ func (factory *AcFactory) NextMsg(rpc *Rpc, accId AccountId) *MsgSnapshot {
198198 return msg
199199}
200200
201- // Introduce two accounts to each other creating a 1:1 chat between them and exchanging messages .
201+ // Introduce two accounts to each other creating a 1:1 chat between them.
202202func (factory * AcFactory ) IntroduceEachOther (rpc1 * Rpc , accId1 AccountId , rpc2 * Rpc , accId2 AccountId ) {
203- chatId := factory .CreateChat (rpc1 , accId1 , rpc2 , accId2 )
204- _ , err := rpc1 .MiscSendTextMessage (accId1 , chatId , "hi" )
203+ qrdata , err := rpc1 .GetChatSecurejoinQrCode (accId1 , option .None [ChatId ]())
205204 if err != nil {
206205 panic (err )
207206 }
208- factory .WaitForEventInChat (rpc1 , accId1 , chatId , EventMsgsChanged {})
209- snapshot := factory .NextMsg (rpc2 , accId2 )
210- if snapshot .Text != "hi" {
211- panic ("unexpected message: " + snapshot .Text )
212- }
213-
214- err = rpc2 .AcceptChat (accId2 , snapshot .ChatId )
207+ _ , err = rpc2 .SecureJoin (accId2 , qrdata )
215208 if err != nil {
216209 panic (err )
217210 }
218- _ , err = rpc2 .MiscSendTextMessage (accId2 , snapshot .ChatId , "hello" )
219- if err != nil {
220- panic (err )
211+
212+ for {
213+ event := factory .WaitForEvent (rpc1 , accId1 , EventSecurejoinInviterProgress {}).(EventSecurejoinInviterProgress )
214+ if event .Progress == 1000 {
215+ break
216+ }
221217 }
222- factory .WaitForEventInChat (rpc2 , accId2 , snapshot .ChatId , EventMsgsChanged {})
223- snapshot = factory .NextMsg (rpc1 , accId1 )
224- if snapshot .Text != "hello" {
225- panic ("unexpected message: " + snapshot .Text )
218+
219+ for {
220+ event := factory .WaitForEvent (rpc2 , accId2 , EventSecurejoinJoinerProgress {}).(EventSecurejoinJoinerProgress )
221+ if event .Progress == 1000 {
222+ break
223+ }
226224 }
227225}
228226
229227// Create a 1:1 chat with accId2 in the chatlist of accId1.
230228func (factory * AcFactory ) CreateChat (rpc1 * Rpc , accId1 AccountId , rpc2 * Rpc , accId2 AccountId ) ChatId {
231- addr2 , err := rpc2 .GetConfig (accId2 , "configured_addr" )
229+ vcard , err := rpc2 .makeVcard (accId2 , [] ContactId { ContactSelf } )
232230 if err != nil {
233231 panic (err )
234232 }
235-
236- contactId , err := rpc1 .CreateContact (accId1 , addr2 .Unwrap (), "" )
233+ ids , err := rpc1 .importVcardContents (accId1 , vcard )
237234 if err != nil {
238235 panic (err )
239236 }
240-
241- chatId , err := rpc1 .CreateChatByContactId (accId1 , contactId )
237+ chatId , err := rpc1 .CreateChatByContactId (accId1 , ids [0 ])
242238 if err != nil {
243239 panic (err )
244240 }
0 commit comments