Repository navigation
fix: do not send a sync message when changing "configured_addr" #8703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,10 +226,11 @@ async fn test_delete_transport() -> Result<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| /// Tests that promoting a transport bumps its `add_timestamp` on other devices | ||
| /// even if it was added within the same second. | ||
| /// Tests that selecting sending transport by setting "configured_addr" does not | ||
| /// send the sync message, is not synchronized between devices even if sync message is forced, | ||
| /// and does not bump sending transport `add_timestamp`. | ||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn test_promote_transport_same_second() -> Result<()> { | ||
| async fn test_no_configured_addr_synchronization() -> Result<()> { | ||
| let mut tcm = TestContextManager::new(); | ||
| let alice = &tcm.alice().await; | ||
| let alice2 = &tcm.alice().await; | ||
|
|
@@ -238,11 +239,35 @@ async fn test_promote_transport_same_second() -> Result<()> { | |
| a.set_config_bool(Config::BccSelf, true).await?; | ||
| } | ||
|
|
||
| add_dummy_transport(alice, "alice@otherprovider.com").await?; | ||
| let addr = "alice@otherprovider.com"; | ||
| add_dummy_transport(alice, addr).await?; | ||
| send_sync_transports(alice).await?; | ||
| sync_and_check_recipients(alice, alice2, "alice@otherprovider.com alice@example.org").await; | ||
| sync_and_check_recipients(alice, alice2, &format!("{addr} alice@example.org")).await; | ||
|
|
||
| // Selects `addr` on `alice` as the sending transport | ||
| // and syncs the transport update to `alice2`, | ||
| // whose own sending transport must stay unchanged. | ||
| let old_timestamp = add_timestamp(alice2, addr).await; | ||
| let alice2_primary = alice2.get_config(Config::ConfiguredAddr).await?; | ||
| alice.set_config(Config::ConfiguredAddr, Some(addr)).await?; | ||
| assert_eq!(add_timestamp(alice, addr).await, old_timestamp); | ||
|
|
||
| promote_transport_and_sync(alice, alice2, "alice@otherprovider.com").await | ||
| send_sync_transports(alice).await?; | ||
| alice.send_sync_msg().await?.unwrap(); | ||
| let sync_msg = alice.pop_sent_msg().await; | ||
| assert_eq!(sync_msg.recipients, format!("alice@example.org {addr}")); | ||
| // The sync message comes from the new sending address, | ||
| // which must not make `alice2` adopt it as its own sending address. | ||
| assert!(sync_msg.payload.contains(&format!("From: <{addr}>"))); | ||
| alice2.recv_msg_trash(&sync_msg).await; | ||
|
|
||
| // add_timestamp must not change. | ||
| assert_eq!(add_timestamp(alice2, addr).await, old_timestamp); | ||
| assert_eq!( | ||
| alice2.get_config(Config::ConfiguredAddr).await?, | ||
| alice2_primary | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Tests that `sync_transports()` requests an IO restart | ||
|
|
@@ -263,36 +288,6 @@ async fn test_sync_transports_requests_io_restart() -> Result<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| /// Promotes `addr` on `alice` and syncs the transport update to `alice2`, | ||
| /// whose own primary transport must stay unchanged. | ||
| async fn promote_transport_and_sync( | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is moved into the test above, but with checks like |
||
| alice: &TestContext, | ||
| alice2: &TestContext, | ||
| addr: &str, | ||
| ) -> Result<()> { | ||
| let old_timestamp = add_timestamp(alice2, addr).await; | ||
| let alice2_primary = alice2.get_config(Config::ConfiguredAddr).await?; | ||
| alice.set_config(Config::ConfiguredAddr, Some(addr)).await?; | ||
| assert!(add_timestamp(alice, addr).await > old_timestamp); | ||
|
|
||
| alice.send_sync_msg().await?.unwrap(); | ||
| let sync_msg = alice.pop_sent_msg().await; | ||
| assert_eq!(sync_msg.recipients, format!("alice@example.org {addr}")); | ||
| // The sync message comes from the new primary, | ||
| // which must not make `alice2` adopt it as its own primary. | ||
| assert!(sync_msg.payload.contains(&format!("From: <{addr}>"))); | ||
| alice2.recv_msg_trash(&sync_msg).await; | ||
|
|
||
| // add_timestamp must monotonically increase because | ||
| // other devices ignore the change otherwise. | ||
| assert!(add_timestamp(alice2, addr).await > old_timestamp); | ||
| assert_eq!( | ||
| alice2.get_config(Config::ConfiguredAddr).await?, | ||
| alice2_primary | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| async fn add_timestamp(t: &TestContext, addr: &str) -> i64 { | ||
| t.sql | ||
| .query_get_value("SELECT add_timestamp FROM transports WHERE addr=?", (addr,)) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to look at the test in detail, it is going to be removed anyway when ConfiguredAddr is not possible to set anymore.