@@ -2964,15 +2964,24 @@ async fn test_sync_accept_before_first_msg() -> Result<()> {
2964
2964
2965
2965
let ba_chat = bob. create_chat ( alice0) . await ;
2966
2966
let sent_msg = bob. send_text ( ba_chat. id , "hi" ) . await ;
2967
- let a0b_chat_id = alice0. recv_msg ( & sent_msg) . await . chat_id ;
2968
- assert_eq ! ( alice0. get_chat( & bob) . await . blocked, Blocked :: Request ) ;
2967
+ let rcvd_msg = alice0. recv_msg ( & sent_msg) . await ;
2968
+ let a0b_chat_id = rcvd_msg. chat_id ;
2969
+ let a0b_contact_id = rcvd_msg. from_id ;
2970
+ assert_eq ! (
2971
+ Chat :: load_from_db( alice0, a0b_chat_id) . await ?. blocked,
2972
+ Blocked :: Request
2973
+ ) ;
2969
2974
a0b_chat_id. accept ( alice0) . await ?;
2970
- let a0b_contact = alice0 . add_or_lookup_contact ( & bob ) . await ;
2975
+ let a0b_contact = Contact :: get_by_id ( alice0 , a0b_contact_id ) . await ? ;
2971
2976
assert_eq ! ( a0b_contact. origin, Origin :: CreateChat ) ;
2972
2977
assert_eq ! ( alice0. get_chat( & bob) . await . blocked, Blocked :: Not ) ;
2973
2978
2974
2979
sync ( alice0, alice1) . await ;
2975
- let a1b_contact = alice1. add_or_lookup_contact ( & bob) . await ;
2980
+ let alice1_contacts = Contact :: get_all ( alice1, 0 , None ) . await ?;
2981
+ assert_eq ! ( alice1_contacts. len( ) , 1 ) ;
2982
+ let a1b_contact_id = alice1_contacts[ 0 ] ;
2983
+ let a1b_contact = Contact :: get_by_id ( alice1, a1b_contact_id) . await ?;
2984
+ assert_eq ! ( a1b_contact. get_addr( ) , "bob@example.net" ) ;
2976
2985
assert_eq ! ( a1b_contact. origin, Origin :: CreateChat ) ;
2977
2986
let a1b_chat = alice1. get_chat ( & bob) . await ;
2978
2987
assert_eq ! ( a1b_chat. blocked, Blocked :: Not ) ;
@@ -2995,22 +3004,22 @@ async fn test_sync_block_before_first_msg() -> Result<()> {
2995
3004
2996
3005
let ba_chat = bob. create_chat ( alice0) . await ;
2997
3006
let sent_msg = bob. send_text ( ba_chat. id , "hi" ) . await ;
2998
- let a0b_chat_id = alice0. recv_msg ( & sent_msg) . await . chat_id ;
3007
+ let rcvd_msg = alice0. recv_msg ( & sent_msg) . await ;
3008
+ let a0b_chat_id = rcvd_msg. chat_id ;
3009
+ let a0b_contact_id = rcvd_msg. from_id ;
2999
3010
assert_eq ! ( alice0. get_chat( & bob) . await . blocked, Blocked :: Request ) ;
3000
3011
a0b_chat_id. block ( alice0) . await ?;
3001
- let a0b_contact = alice0 . add_or_lookup_contact ( & bob ) . await ;
3012
+ let a0b_contact = Contact :: get_by_id ( alice0 , a0b_contact_id ) . await ? ;
3002
3013
assert_eq ! ( a0b_contact. origin, Origin :: IncomingUnknownFrom ) ;
3003
3014
assert_eq ! ( alice0. get_chat( & bob) . await . blocked, Blocked :: Yes ) ;
3004
3015
3005
3016
sync ( alice0, alice1) . await ;
3006
- let a1b_contact = alice1. add_or_lookup_contact ( & bob) . await ;
3007
- assert_eq ! ( a1b_contact. origin, Origin :: Hidden ) ;
3008
- assert ! ( ChatIdBlocked :: lookup_by_contact( alice1, a1b_contact. id)
3009
- . await ?
3010
- . is_none( ) ) ;
3017
+ let alice1_contacts = Contact :: get_all ( alice1, 0 , None ) . await ?;
3018
+ assert_eq ! ( alice1_contacts. len( ) , 0 ) ;
3011
3019
3012
3020
let rcvd_msg = alice1. recv_msg ( & sent_msg) . await ;
3013
- let a1b_contact = alice1. add_or_lookup_contact ( & bob) . await ;
3021
+ let a1b_contact_id = rcvd_msg. from_id ;
3022
+ let a1b_contact = Contact :: get_by_id ( alice1, a1b_contact_id) . await ?;
3014
3023
assert_eq ! ( a1b_contact. origin, Origin :: IncomingUnknownFrom ) ;
3015
3024
let a1b_chat = alice1. get_chat ( & bob) . await ;
3016
3025
assert_eq ! ( a1b_chat. blocked, Blocked :: Yes ) ;
0 commit comments