deltachat / deltachat-core-rust

Delta Chat Rust Core library, used by Android/iOS/desktop apps, bindings and bots 📧
https://delta.chat/en/contribute
Other
671 stars 84 forks source link

Dev: unit tests failing on current commit without any change #5878

Closed ooggss closed 3 months ago

ooggss commented 3 months ago

Operating System

linux

Delta Chat version

commit:36a480fec8ca23dbbbd490b76d485616f3591e28

Expected behavior

unit tests passing

Actual behavior

2 unit test failing

Steps to reproduce the problem

1、Checkout current HEAD (36a480fec8ca23dbbbd490b76d485616f3591e28) of the deltachat-core-rust repository 2、run cargo test

Debug logs

failures:

---- oauth2::tests::test_oauth_from_mx stdout ----
thread 'oauth2::tests::test_oauth_from_mx' panicked at src/oauth2.rs:411:9:
assertion `left == right` failed
  left: None
 right: Some(Oauth2 { client_id: "959970109878-4mvtgf6feshskf7695nfln6002mom908.apps.googleusercontent.com", get_code: "https://accounts.google.com/o/oauth2/auth?client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI&response_type=code&scope=https%3A%2F%2Fmail.google.com%2F%20email&access_type=offline", init_token: "https://accounts.google.com/o/oauth2/token?client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI&code=$CODE&grant_type=authorization_code", refresh_token: "https://accounts.google.com/o/oauth2/token?client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI&refresh_token=$REFRESH_TOKEN&grant_type=refresh_token", get_userinfo: Some("https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=$ACCESS_TOKEN") })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

========== Chats of 2803061939: ==========

2803061939 WARN: src/provider.rs:250: Cannot resolve MX records for "youtube.com".

---- securejoin::tests::test_setup_contact_wrong_alice_gossip stdout ----
thread 'securejoin::tests::test_setup_contact_wrong_alice_gossip' panicked at src/securejoin.rs:870:9:
assertion `left == right` failed
  left: true
 right: false

========== Chats of bob: ==========
Single#Chat#10: alice@example.org [alice@example.org] 
--------------------------------------------------------------------------------
Msg#11: info (Contact#Contact#Info): Establishing guaranteed end-to-end encryption, please wait… [NOTICED][INFO]
Msg#12: info (Contact#Contact#Info): Could not yet establish guaranteed end-to-end encryption, but you may already send a message. [NOTICED][INFO]
--------------------------------------------------------------------------------

========== Chats of alice: ==========
Single#Chat#10: bob@example.net [bob@example.net] 

bob Received Event { id: 2464967561, typ: ConfigSynced { key: Displayname } }
alice INFO: src/securejoin.rs:128: Generated QR code.
alice Received Event { id: 784339124, typ: ConfigSynced { key: Displayname } }
bob INFO: src/securejoin.rs:163: Requesting secure-join ...
bob INFO: src/contact.rs:932: Added contact id=10 addr=alice@example.org.
bob Received MSGS_CHANGED(chat_id=Chat#Special0, msg_id=Msg#0)
bob Received Event { id: 2464967561, typ: ChatlistChanged }
bob Received Event { id: 2464967561, typ: ChatlistItemChanged { chat_id: Some(ChatId(10)) } }
bob INFO: src/mimefactory.rs:1171: Sending secure-join message "vc-request".
bob Received MSGS_CHANGED(chat_id=Chat#10, msg_id=Msg#11)
bob Received Event { id: 2464967561, typ: ChatlistChanged }
bob Received Event { id: 2464967561, typ: ChatlistItemChanged { chat_id: Some(ChatId(10)) } }
alice INFO: src/receive_imf.rs:221: Receiving message "Mr.Wsae7Jd_lAg.crM9kTB7zgU@localhost", seen=false...
alice INFO: src/contact.rs:932: Added contact id=10 addr=bob@example.net.
alice INFO: src/securejoin.rs:295: Received secure-join message "vc-request".
alice Received Event { id: 784339124, typ: SecurejoinInviterProgress { contact_id: ContactId(10), progress: 300 } }
alice Received MSGS_CHANGED(chat_id=Chat#Special0, msg_id=Msg#0)
alice Received Event { id: 784339124, typ: ChatlistChanged }
alice Received Event { id: 784339124, typ: ChatlistItemChanged { chat_id: Some(ChatId(10)) } }
alice INFO: src/e2ee.rs:66: Peerstate for "bob@example.net" is mutual.
alice INFO: src/mimefactory.rs:1171: Sending secure-join message "vc-auth-required".
alice INFO: src/chat.rs:1352: Set gossiped_timestamp for chat Chat#10 to 1723999356.
alice Received CONTACTS_CHANGED(contact=Some(ContactId(10)))
bob Received MSGS_CHANGED(chat_id=Chat#Special0, msg_id=Msg#0)
bob Received Event { id: 2464967561, typ: ChatlistChanged }
bob Received Event { id: 2464967561, typ: ChatlistItemChanged { chat_id: Some(ChatId(10)) } }
bob Received MSGS_CHANGED(chat_id=Chat#10, msg_id=Msg#12)
bob Received Event { id: 2464967561, typ: ChatlistChanged }
bob Received Event { id: 2464967561, typ: ChatlistItemChanged { chat_id: Some(ChatId(10)) } }
bob Received CHAT_MODIFIED(Chat#10)

failures:
    oauth2::tests::test_oauth_from_mx
    securejoin::tests::test_setup_contact_wrong_alice_gossip

test result: FAILED. 835 passed; 2 failed; 1 ignored; 0 measured; 0 filtered out; finished in 89.44s
link2xt commented 3 months ago

Failure to resolve MX record of youtube.com is a problem with your system resolver. Normally the results looks like this:

$ dig +short MX youtube.com
0 smtp.google.com.

As for securejoin::tests::test_setup_contact_wrong_alice_gossip it should not fail like this and passes in CI. Is it reproducible?

Also make sure to use cargo nextest run instead of cargo test.

ooggss commented 3 months ago

Failure to resolve MX record of youtube.com is a problem with your system resolver. Normally the results looks like this:

$ dig +short MX youtube.com
0 smtp.google.com.

As for securejoin::tests::test_setup_contact_wrong_alice_gossip it should not fail like this and passes in CI. Is it reproducible?

Also make sure to use cargo nextest run instead of cargo test.

Thanks for your reply!!

for "resolve MX record", I use dig +short MX youtube.com but got nothing

and for "securejoin::tests::test_setup_contact_wrong_alice_gossip", I try it again without any change but it passes this time

Besides, cargo nextest run does speed up the process. Thanks a lot!

link2xt commented 3 months ago

for "resolve MX record", I use dig +short MX youtube.com but got nothing

Apparently your DNS resolver is faulty or censored. Consider configuring your system to use some DNS over HTTPS server or DNS over TLS if you use systemd-resolved as it still does not support DoH.

As for cargo test, it does not isolate tests and runs multiple tests in the same process, which may result in spurious failures. cargo nextest run runs each test in a separate process.

link2xt commented 3 months ago

securejoin::tests::test_setup_contact_wrong_alice_gossip uses test_setup_contact_ex which uses SystemTime::shift internally, so pretty sure failure was caused by using cargo test instead of cargo nextest run and some other test shifting the time.

As for MX resolution results, this is not a problem with the test.