Skip to content

test: add tests e2e with bartender - #303

Merged
jlucaso1 merged 2 commits into
mainfrom
feat-e2e-test-bartender
Mar 8, 2026
Merged

test: add tests e2e with bartender#303
jlucaso1 merged 2 commits into
mainfrom
feat-e2e-test-bartender

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Mar 8, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Presence handling added: availability status and last-seen are published to the event stream; chat state events now emit presence updates.
  • Tests

    • New end-to-end test suite for connection flows, reconnect behavior, bidirectional messaging, message revoke, typing indicators, and presence propagation.
  • Chores

    • Removed unused dependencies and newsletter data model types.
    • Added automated end-to-end testing workflow and adjusted CI build/test to exclude e2e from regular runs.

@coderabbitai

coderabbitai Bot commented Mar 8, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@jlucaso1 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eaad7483-3b42-4bb6-b3cf-a03454cadad8

📥 Commits

Reviewing files that changed from the base of the PR and between 6737e72 and 277c89c.

📒 Files selected for processing (5)
  • .github/workflows/e2e.yml
  • Cargo.toml
  • tests/e2e/src/lib.rs
  • tests/e2e/tests/connection.rs
  • tests/e2e/tests/messaging.rs
📝 Walkthrough

Walkthrough

Adds end-to-end test infrastructure and GitHub Actions workflow, introduces a PresenceHandler that parses and dispatches presence stanzas, removes newsletter types and the rand_core dependency, and adjusts workspace manifests and build/test CI to exclude e2e-tests from standard runs.

Changes

Cohort / File(s) Summary
E2E Testing Infrastructure
.github/workflows/e2e.yml, tests/e2e/Cargo.toml, tests/e2e/src/lib.rs, tests/e2e/tests/connection.rs, tests/e2e/tests/messaging.rs, tests/e2e/tests/presence.rs
Adds a GitHub Actions E2E workflow and a new workspace tests/e2e with test helpers (TestClient, ChannelEventHandler, test store), and multiple async end-to-end tests for connection, messaging, revocation, typing, and presence flows.
Presence Stanza Handler
src/handlers/presence.rs, src/handlers/mod.rs, src/client.rs
Adds PresenceHandler (parses stanzas, extracts JID, unavailable flag, last-seen, dispatches Presence updates) and registers it in stanza router; client now publishes ChatPresenceUpdate to event bus before legacy ChatStateEvent callbacks.
Dependency & Workspace Changes
Cargo.toml, wacore/Cargo.toml, wacore/noise/Cargo.toml, wacore/binary/Cargo.toml
Removes rand_core from workspace and package manifests, removes dev-dep hex from wacore/noise, and adds package.metadata.cargo-shear ignore for phf in wacore/binary/Cargo.toml.
Type Removals
wacore/src/types/newsletter.rs
Removes the entire newsletter data model module: enums and structs modeling newsletter states, metadata, threads, viewer settings, and messages.
CI Build/Test Adjustment
.github/workflows/main.yml
Modifies main CI build/test steps to use --workspace and explicitly --exclude e2e-tests for build and test runs.

Sequence Diagram(s)

sequenceDiagram
    participant Stanza as "Stanza (incoming <presence>)"
    participant PresenceHandler as "PresenceHandler"
    participant EventBus as "Event Bus"
    participant Legacy as "Legacy ChatState Callbacks"

    Stanza->>PresenceHandler: handle(stanza)
    PresenceHandler->>PresenceHandler: parse from, type, last
    PresenceHandler->>EventBus: dispatch PresenceUpdate(from, unavailable, last_seen)
    PresenceHandler->>Legacy: create ChatStateEvent and call callbacks
    EventBus-->>Legacy: (subscribers receive PresenceUpdate)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Poem

🐰 A twitch, a hop, a presence in flight,
E2E tests wake up through day and night.
Handlers listen, events softly hum,
Old newsletter shadows—gone, be done!
The rabbit cheers: tests pass—bring the carrot! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add tests e2e with bartender' accurately reflects the main changes: adding comprehensive end-to-end tests using a mock server (bartender) infrastructure including GitHub Actions workflow, test utilities, and multiple test suites.
Docstring Coverage ✅ Passed Docstring coverage is 94.44% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-e2e-test-bartender

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Mar 8, 2026

Copy link
Copy Markdown

🐰 Bencher Report

Branchfeat-e2e-test-bartender
Testbedubuntu-latest

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
binary_benchmark::unpack_group::bench_unpack_compressedInstructions
instructions x 1e3
📈 plot
🚷 threshold
🚨 alert (🔔)
556.09 x 1e3
(+6.55%)Baseline: 521.89 x 1e3
547.98 x 1e3
(101.48%)

Click to view all benchmark results
BenchmarkInstructionsBenchmark Result
instructions
(Result Δ%)
Upper Boundary
instructions
(Limit %)
binary_benchmark::attr_parser_group::bench_attr_parser attr_lookup:setup_attr_marshaled()📈 view plot
🚷 view threshold
6,124.00
(-13.59%)Baseline: 7,087.54
7,441.92
(82.29%)
binary_benchmark::child_iteration_group::bench_get_children_by_tag📈 view plot
🚷 view threshold
850,787.00
(+0.00%)Baseline: 850,758.14
893,296.04
(95.24%)
binary_benchmark::jid_optimization_group::bench_jid_to_owned_access jid_access:setup_jid_heavy_marshaled()📈 view plot
🚷 view threshold
22,227.00
(-7.39%)Baseline: 24,000.60
25,200.63
(88.20%)
binary_benchmark::marshal_group::bench_marshal_allocating📈 view plot
🚷 view threshold
119,186.00
(-11.10%)Baseline: 134,061.30
140,764.36
(84.67%)
binary_benchmark::marshal_group::bench_marshal_auto_allocating📈 view plot
🚷 view threshold
119,214.00
(-0.00%)Baseline: 119,218.86
125,179.80
(95.23%)
binary_benchmark::marshal_group::bench_marshal_auto_huge_bytes_allocating📈 view plot
🚷 view threshold
534,031.00
(+0.00%)Baseline: 534,030.43
560,731.95
(95.24%)
binary_benchmark::marshal_group::bench_marshal_auto_long_string📈 view plot
🚷 view threshold
17,350.00
(0.00%)Baseline: 17,350.00
18,217.50
(95.24%)
binary_benchmark::marshal_group::bench_marshal_auto_many_children_allocating📈 view plot
🚷 view threshold
17,133,858.00
(-0.00%)Baseline: 17,134,255.29
17,990,968.05
(95.24%)
binary_benchmark::marshal_group::bench_marshal_exact_allocating📈 view plot
🚷 view threshold
176,687.00
(-0.00%)Baseline: 176,691.86
185,526.45
(95.24%)
binary_benchmark::marshal_group::bench_marshal_exact_huge_bytes_allocating📈 view plot
🚷 view threshold
535,444.00
(+0.00%)Baseline: 535,443.43
562,215.60
(95.24%)
binary_benchmark::marshal_group::bench_marshal_exact_long_string📈 view plot
🚷 view threshold
19,404.00
(0.00%)Baseline: 19,404.00
20,374.20
(95.24%)
binary_benchmark::marshal_group::bench_marshal_exact_many_children_allocating📈 view plot
🚷 view threshold
42,766,353.00
(-0.00%)Baseline: 42,767,142.14
44,905,499.25
(95.24%)
binary_benchmark::marshal_group::bench_marshal_huge_bytes_allocating📈 view plot
🚷 view threshold
534,470.00
(+0.00%)Baseline: 534,469.43
561,192.90
(95.24%)
binary_benchmark::marshal_group::bench_marshal_long_string📈 view plot
🚷 view threshold
17,323.00
(-8.29%)Baseline: 18,888.11
19,832.51
(87.35%)
binary_benchmark::marshal_group::bench_marshal_many_children_allocating📈 view plot
🚷 view threshold
17,134,657.00
(-0.00%)Baseline: 17,135,060.71
17,991,813.75
(95.24%)
binary_benchmark::marshal_group::bench_marshal_reusing_buffer📈 view plot
🚷 view threshold
129,087.00
(-4.71%)Baseline: 135,468.56
142,241.99
(90.75%)
binary_benchmark::marshal_group::bench_marshal_reusing_buffer_vec_writer📈 view plot
🚷 view threshold
119,286.00
(-0.00%)Baseline: 119,290.86
125,255.40
(95.23%)
binary_benchmark::roundtrip_group::bench_roundtrip large:setup_large_marshaled()📈 view plot
🚷 view threshold
93,716.00
(-9.77%)Baseline: 103,858.17
109,051.07
(85.94%)
binary_benchmark::roundtrip_group::bench_roundtrip small:setup_small_marshaled()📈 view plot
🚷 view threshold
7,249.00
(-12.11%)Baseline: 8,247.61
8,659.99
(83.71%)
binary_benchmark::roundtrip_group::bench_roundtrip_auto large:setup_large_marshaled()📈 view plot
🚷 view threshold
93,747.00
(+0.01%)Baseline: 93,740.57
98,427.60
(95.24%)
binary_benchmark::roundtrip_group::bench_roundtrip_auto small:setup_small_marshaled()📈 view plot
🚷 view threshold
7,272.00
(0.00%)Baseline: 7,272.00
7,635.60
(95.24%)
binary_benchmark::roundtrip_group::bench_roundtrip_exact large:setup_large_marshaled()📈 view plot
🚷 view threshold
109,532.00
(+0.01%)Baseline: 109,525.57
115,001.85
(95.24%)
binary_benchmark::roundtrip_group::bench_roundtrip_exact small:setup_small_marshaled()📈 view plot
🚷 view threshold
8,784.00
(0.00%)Baseline: 8,784.00
9,223.20
(95.24%)
binary_benchmark::unmarshal_group::bench_unmarshal large:setup_large_marshaled()📈 view plot
🚷 view threshold
44,794.00
(-8.22%)Baseline: 48,807.61
51,247.99
(87.41%)
binary_benchmark::unmarshal_group::bench_unmarshal small:setup_small_marshaled()📈 view plot
🚷 view threshold
2,588.00
(-15.49%)Baseline: 3,062.27
3,215.38
(80.49%)
binary_benchmark::unpack_group::bench_unpack_compressed📈 view plot
🚷 view threshold
🚨 view alert (🔔)
556,092.00
(+6.55%)Baseline: 521,890.10
547,984.61
(101.48%)

binary_benchmark::unpack_group::bench_unpack_uncompressed📈 view plot
🚷 view threshold
771.00
(-0.77%)Baseline: 776.95
815.80
(94.51%)
libsignal_benchmark::conversation_group::bench_full_dm_conversation full:setup_conversation_data()📈 view plot
🚷 view threshold
27,684,195.00
(-0.24%)Baseline: 27,751,031.70
29,138,583.29
(95.01%)
libsignal_benchmark::dm_group::bench_dm_decrypt_first_message decrypt_prekey:setup_dm_with_first_message()📈 view plot
🚷 view threshold
5,540,324.00
(-0.35%)Baseline: 5,559,883.04
5,837,877.19
(94.90%)
libsignal_benchmark::dm_group::bench_dm_encrypt_first_message first_msg:setup_dm_session()📈 view plot
🚷 view threshold
178,096.00
(+0.06%)Baseline: 177,990.61
186,890.14
(95.29%)
libsignal_benchmark::dm_group::bench_dm_encrypt_subsequent_message subsequent:setup_established_dm_session()📈 view plot
🚷 view threshold
178,907.00
(+0.06%)Baseline: 178,802.28
187,742.40
(95.29%)
libsignal_benchmark::dm_group::bench_dm_session_establishment setup:setup_dm_users()📈 view plot
🚷 view threshold
17,266,834.00
(-0.08%)Baseline: 17,281,441.27
18,145,513.33
(95.16%)
libsignal_benchmark::group_messaging_group::bench_group_create_distribution_message create:setup_group_sender()📈 view plot
🚷 view threshold
295,884.00
(+0.02%)Baseline: 295,813.35
310,604.02
(95.26%)
libsignal_benchmark::group_messaging_group::bench_group_decrypt_message decrypt:setup_group_with_encrypted_message()📈 view plot
🚷 view threshold
12,544,284.00
(-0.44%)Baseline: 12,599,878.70
13,229,872.64
(94.82%)
libsignal_benchmark::group_messaging_group::bench_group_encrypt_message encrypt:setup_group_with_distribution()📈 view plot
🚷 view threshold
715,609.00
(-0.03%)Baseline: 715,818.22
751,609.13
(95.21%)
libsignal_benchmark::session_optimization_group::bench_decrypt_with_previous_session previous_session:setup_with_archived_sessions()📈 view plot
🚷 view threshold
41,823.00
(+0.06%)Baseline: 41,795.93
43,885.72
(95.30%)
libsignal_benchmark::session_optimization_group::bench_message_key_eviction eviction:setup_message_key_eviction()📈 view plot
🚷 view threshold
15,561,842.00
(+0.00%)Baseline: 15,561,495.91
16,339,570.71
(95.24%)
libsignal_benchmark::session_optimization_group::bench_out_of_order_decryption out_of_order:setup_out_of_order_messages()📈 view plot
🚷 view threshold
5,504,879.00
(-0.27%)Baseline: 5,519,721.42
5,795,707.49
(94.98%)
libsignal_benchmark::session_optimization_group::bench_promote_matching_session promote:setup_promote_matching_session()📈 view plot
🚷 view threshold
956,776.00
(-0.53%)Baseline: 961,871.04
1,009,964.59
(94.73%)
libsignal_benchmark::signature_group::bench_key_generation keygen📈 view plot
🚷 view threshold
2,822,723.00
(-0.01%)Baseline: 2,823,088.68
2,964,243.11
(95.23%)
libsignal_benchmark::signature_group::bench_signature_creation sign:setup_keypair_with_message()📈 view plot
🚷 view threshold
3,444,364.00
(-2.60%)Baseline: 3,536,299.71
3,713,114.70
(92.76%)
libsignal_benchmark::signature_group::bench_signature_verification verify:setup_keypair_with_message()📈 view plot
🚷 view threshold
124,928,225.00
(-0.45%)Baseline: 125,495,553.89
131,770,331.59
(94.81%)
reporting_token_benchmark::content_extraction_group::bench_content_extraction extended:setup_extended_message()📈 view plot
🚷 view threshold
11,800.00
(+0.09%)Baseline: 11,788.95
12,378.40
(95.33%)
reporting_token_benchmark::content_extraction_group::bench_content_extraction simple:setup_simple_message()📈 view plot
🚷 view threshold
3,822.00
(-0.01%)Baseline: 3,822.48
4,013.60
(95.23%)
reporting_token_benchmark::full_generation_group::bench_full_token_generation extended:setup_full_gen_extended()📈 view plot
🚷 view threshold
87,958.00
(-0.02%)Baseline: 87,972.48
92,371.10
(95.22%)
reporting_token_benchmark::full_generation_group::bench_full_token_generation simple:setup_full_gen_simple()📈 view plot
🚷 view threshold
80,003.00
(-0.03%)Baseline: 80,029.00
84,030.45
(95.21%)
reporting_token_benchmark::key_derivation_group::bench_key_derivation📈 view plot
🚷 view threshold
51,008.00
(-0.04%)Baseline: 51,028.56
53,579.99
(95.20%)
reporting_token_benchmark::message_encoding_group::bench_message_encoding extended:setup_extended_message()📈 view plot
🚷 view threshold
5,754.00
(+0.30%)Baseline: 5,736.50
6,023.33
(95.53%)
reporting_token_benchmark::message_encoding_group::bench_message_encoding simple:setup_simple_message()📈 view plot
🚷 view threshold
2,119.00
(+0.17%)Baseline: 2,115.49
2,221.26
(95.40%)
reporting_token_benchmark::token_calculation_group::bench_token_calculation📈 view plot
🚷 view threshold
21,920.00
(+0.03%)Baseline: 21,912.47
23,008.09
(95.27%)
🐰 View full continuous benchmarking report in Bencher

@jlucaso1
jlucaso1 force-pushed the feat-e2e-test-bartender branch from e313324 to 6737e72 Compare March 8, 2026 00:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Cargo.toml (1)

12-18: ⚠️ Potential issue | 🟠 Major

Don't make workspace-wide test runs depend on bartender.

Adding tests/e2e as a normal workspace member means cargo test --all now pulls in tests that default to wss://127.0.0.1:8080/ws/chat and wait up to 30 seconds for pairing/connection in tests/e2e/src/lib.rs. On machines or CI jobs without the mock server, the standard workspace test command will now hang/fail. Please keep these tests opt-in (for example via ignored tests/env gating or a separate manifest invocation) instead of making them part of the default workspace test surface.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Cargo.toml` around lines 12 - 18, Remove the end-to-end tests from the
default workspace test surface: delete "tests/e2e" from the workspace members
list in Cargo.toml (the workspace members array) and instead make the e2e tests
opt-in by either adding #[ignore] or an environment-gated skip in
tests/e2e/src/lib.rs (for example check a CI env var like RUN_E2E and
early-return/skip when not set), or run them via a separate manifest invocation;
ensure references to the e2e crate name ("tests/e2e") are removed from the
members list so cargo test --all no longer executes those network-dependent
tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/e2e.yml:
- Around line 39-43: The "Wait for mock server" step's readiness loop currently
always succeeds (exits 0) even if curl never succeeds; update the shell snippet
that runs the for loop with curl -k https://localhost:8080/ so that if the loop
completes without a successful probe it exits with a non-zero status (e.g., test
the loop result and call exit 1 or append a failing command), ensuring the
GitHub Actions step fails when the mock server never became ready.

In `@tests/e2e/src/lib.rs`:
- Around line 53-96: The connect helper currently leaves the background bot task
running when the wait loop times out or event_rx.recv() errors; ensure you clean
up by aborting the run_handle and disconnecting the client before returning or
panicking. In connect, on the timeout error path (the map_err result) and inside
the event_rx Err branch, call run_handle.abort() (or stop/await it if the handle
type requires) and call client.disconnect() (or await if async) to tear down the
bot before returning the error or panicking; reference symbols: connect,
bot.run(), run_handle, client, and event_rx.

In `@tests/e2e/tests/connection.rs`:
- Around line 47-70: The event loop inside the tokio::time::timeout currently
only breaks in the Event::Connected arm, so if Event::Connected arrives before
Event::PairSuccess the loop never exits; update the handlers for
Event::PairSuccess and Event::Connected (the match on event_rx.recv() inside the
async loop) to set their respective flags and then check if both
got_pair_success and got_connected are true and break when they are, ensuring
either arm can trigger the exit when the other flag is already set.

In `@tests/e2e/tests/messaging.rs`:
- Around line 100-105: The test currently unwraps the awaited event with a
conditional matching Event::Message and asserts msg.conversation but omits an
else branch, allowing non-Message events to silently pass; update the block that
handles the result of client_b.wait_for_event (the match on Event::Message) to
include an else arm that fails the test (e.g., panic! or assert!(false) with a
clear message) when the event is not Event::Message so the test fails when an
unexpected event type is returned; reference the wait_for_event call, the
Event::Message pattern, msg.conversation and text_a when adding the failing
branch.
- Around line 120-125: The match arm for client_a.wait_for_event(...) only
handles Event::Message but lacks an else branch causing silent test false
positives; update the block that awaits client_a.wait_for_event(30, |e|
matches!(e, Event::Message(_, _))).await? to include an else branch (e.g.,
panic! or assert!(false, ...)) when the event is not Event::Message and include
the received event in the failure message, then assert
msg.conversation.as_deref() == Some(text_b) as before; apply the identical
change to the symmetric B→A wait_for_event block so both directions fail loudly
with diagnostics when the pattern doesn't match.
- Around line 14-19: The variable jid_a is computed but never used; remove the
unused binding by either omitting the assignment (await
client_a.client.get_pn().await... .to_non_ad(); if side effects needed) or
change the binding to a discard (e.g., _jid_a) so the call remains but the
compiler won't warn; update the code around the expression using
client_a.client.get_pn() and to_non_ad() accordingly to avoid the
unused-variable warning.

---

Outside diff comments:
In `@Cargo.toml`:
- Around line 12-18: Remove the end-to-end tests from the default workspace test
surface: delete "tests/e2e" from the workspace members list in Cargo.toml (the
workspace members array) and instead make the e2e tests opt-in by either adding
#[ignore] or an environment-gated skip in tests/e2e/src/lib.rs (for example
check a CI env var like RUN_E2E and early-return/skip when not set), or run them
via a separate manifest invocation; ensure references to the e2e crate name
("tests/e2e") are removed from the members list so cargo test --all no longer
executes those network-dependent tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 59831df5-cf17-4e29-a35f-8c0d6561010d

📥 Commits

Reviewing files that changed from the base of the PR and between 979a395 and e313324.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • .github/workflows/e2e.yml
  • Cargo.toml
  • src/client.rs
  • src/handlers/mod.rs
  • src/handlers/presence.rs
  • tests/e2e/Cargo.toml
  • tests/e2e/src/lib.rs
  • tests/e2e/tests/connection.rs
  • tests/e2e/tests/messaging.rs
  • tests/e2e/tests/presence.rs
  • wacore/Cargo.toml
  • wacore/binary/Cargo.toml
  • wacore/noise/Cargo.toml
  • wacore/src/types/newsletter.rs
💤 Files with no reviewable changes (3)
  • wacore/noise/Cargo.toml
  • wacore/Cargo.toml
  • wacore/src/types/newsletter.rs

Comment thread .github/workflows/e2e.yml
Comment thread tests/e2e/src/lib.rs Outdated
Comment on lines +47 to +70
let result = tokio::time::timeout(timeout, async {
loop {
match event_rx.recv().await {
Ok(Event::PairSuccess(ps)) => {
info!("Received PairSuccess: {:?}", ps);
got_pair_success = true;
}
Ok(Event::Connected(_)) => {
info!("Received Connected event");
got_connected = true;
if got_pair_success {
break;
}
}
Ok(event) => {
info!("Received event: {:?}", event);
}
Err(e) => {
panic!("Event channel error: {}", e);
}
}
}
})
.await;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Event loop may timeout if Connected arrives before PairSuccess.

The loop only checks for break in the Connected arm. If events arrive in order ConnectedPairSuccess, the loop sets both flags but never breaks—it will timeout waiting for another event.

🐛 Proposed fix
             Ok(Event::PairSuccess(ps)) => {
                 info!("Received PairSuccess: {:?}", ps);
                 got_pair_success = true;
+                if got_connected {
+                    break;
+                }
             }
             Ok(Event::Connected(_)) => {
                 info!("Received Connected event");
                 got_connected = true;
                 if got_pair_success {
                     break;
                 }
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/tests/connection.rs` around lines 47 - 70, The event loop inside
the tokio::time::timeout currently only breaks in the Event::Connected arm, so
if Event::Connected arrives before Event::PairSuccess the loop never exits;
update the handlers for Event::PairSuccess and Event::Connected (the match on
event_rx.recv() inside the async loop) to set their respective flags and then
check if both got_pair_success and got_connected are true and break when they
are, ensuring either arm can trigger the exit when the other flag is already
set.

Comment thread tests/e2e/tests/messaging.rs Outdated
Comment thread tests/e2e/tests/messaging.rs
Comment thread tests/e2e/tests/messaging.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/e2e/tests/messaging.rs (1)

14-19: Consider removing or prefixing jid_a if only used for logging.

The variable jid_a is computed but only used in the log statement at line 27. If the logging isn't essential for debugging, consider removing this binding or prefixing with _ to indicate it's intentionally unused for the core test logic.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/tests/messaging.rs` around lines 14 - 19, The binding jid_a is only
used for logging and should be made clearly optional: either remove the jid_a
variable entirely and log nothing, or prefix it with an underscore (e.g.,
_jid_a) to mark it as intentionally unused while keeping the log; update the log
call to use the new name if keeping it (or remove the log statement if dropping
the binding). Locate the code where
client_a.client.get_pn().await.expect(...).to_non_ad() is assigned to jid_a and
apply one of these two changes to eliminate the unused-binding warning.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/e2e/tests/messaging.rs`:
- Around line 186-193: The test currently only checks the revoke protocol
message inside an if let Event::Message(msg, _) = event { ... } block and lacks
an else branch to explicitly fail when the event is not Event::Message; add an
else branch to the if let that calls panic! or assert!(false, ...) with a clear
message (e.g., "Expected Event::Message with revoke protocol message, got
{event:?}") so the test fails loudly when the pattern doesn't match; locate the
block using Event::Message, proto, and the assert_eq comparing proto.r#type() to
wa::message::protocol_message::Type::Revoke and add the explicit else branch
there.

---

Nitpick comments:
In `@tests/e2e/tests/messaging.rs`:
- Around line 14-19: The binding jid_a is only used for logging and should be
made clearly optional: either remove the jid_a variable entirely and log
nothing, or prefix it with an underscore (e.g., _jid_a) to mark it as
intentionally unused while keeping the log; update the log call to use the new
name if keeping it (or remove the log statement if dropping the binding). Locate
the code where client_a.client.get_pn().await.expect(...).to_non_ad() is
assigned to jid_a and apply one of these two changes to eliminate the
unused-binding warning.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f0ab3b4-af88-47cc-ad47-abb001a97d77

📥 Commits

Reviewing files that changed from the base of the PR and between e313324 and 6737e72.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (15)
  • .github/workflows/e2e.yml
  • .github/workflows/main.yml
  • Cargo.toml
  • src/client.rs
  • src/handlers/mod.rs
  • src/handlers/presence.rs
  • tests/e2e/Cargo.toml
  • tests/e2e/src/lib.rs
  • tests/e2e/tests/connection.rs
  • tests/e2e/tests/messaging.rs
  • tests/e2e/tests/presence.rs
  • wacore/Cargo.toml
  • wacore/binary/Cargo.toml
  • wacore/noise/Cargo.toml
  • wacore/src/types/newsletter.rs
💤 Files with no reviewable changes (3)
  • wacore/Cargo.toml
  • wacore/noise/Cargo.toml
  • wacore/src/types/newsletter.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/handlers/mod.rs
  • src/handlers/presence.rs
  • Cargo.toml

Comment thread tests/e2e/tests/messaging.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant