Skip to content

Commit a4155b0

Browse files
committed
reintroduce Config::FailOnReceivingFullMsg but renamed it to
`Config::SimulateReceiveImfError`
1 parent 2387d22 commit a4155b0

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

deltachat-rpc-client/tests/test_something.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def test_receive_imf_failure(acfactory) -> None:
336336
alice_contact_bob = alice.create_contact(bob, "Bob")
337337
alice_chat_bob = alice_contact_bob.create_chat()
338338

339-
bob.set_config("fail_on_receiving_full_msg", "1")
339+
bob.set_config("simulate_receive_imf_error", "1")
340340
alice_chat_bob.send_text("Hello!")
341341
event = bob.wait_for_event(EventType.MSGS_CHANGED)
342342
assert event.chat_id == bob.get_device_chat().id
@@ -345,12 +345,12 @@ def test_receive_imf_failure(acfactory) -> None:
345345
snapshot = message.get_snapshot()
346346
assert (
347347
snapshot.text == "❌ Failed to receive a message:"
348-
" Condition failed: `!context.get_config_bool(Config::FailOnReceivingFullMsg).await?`."
348+
" Condition failed: `!context.get_config_bool(Config::SimulateReceiveImfError).await?`."
349349
" Please report this bug to delta@merlinux.eu or https://support.delta.chat/."
350350
)
351351

352352
# The failed message doesn't break the IMAP loop.
353-
bob.set_config("fail_on_receiving_full_msg", "0")
353+
bob.set_config("simulate_receive_imf_error", "0")
354354
alice_chat_bob.send_text("Hello again!")
355355
event = bob.wait_for_incoming_msg_event()
356356
msg_id = event.msg_id

src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ pub enum Config {
437437
/// to avoid encrypting it differently and
438438
/// storing the same token multiple times on the server.
439439
EncryptedDeviceToken,
440+
441+
/// Return an error from `receive_imf_inner()`. For tests.
442+
SimulateReceiveImfError,
440443
}
441444

442445
impl Config {

src/receive_imf.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ pub(crate) async fn receive_imf_inner(
469469
imf_raw: &[u8],
470470
seen: bool,
471471
) -> Result<Option<ReceivedMsg>> {
472+
ensure!(
473+
!context
474+
.get_config_bool(Config::SimulateReceiveImfError)
475+
.await?
476+
);
472477
if std::env::var(crate::DCC_MIME_DEBUG).is_ok() {
473478
info!(
474479
context,

0 commit comments

Comments
 (0)