From ec4274f39e1dac7f5e1985cf26c72c0cd3c56e82 Mon Sep 17 00:00:00 2001 From: damocles Date: Mon, 16 Nov 2026 23:21:37 +0100 Subject: [PATCH] hive-matrix-mcp: test the room handlers against the SDK's mock homeserver --- Cargo.lock | 304 ++++++++++++++++++++- hive-matrix-mcp/Cargo.toml | 3 + hive-matrix-mcp/src/handlers.rs | 4 + hive-matrix-mcp/src/handlers_mock_tests.rs | 238 ++++++++++++++++ 4 files changed, 546 insertions(+), 3 deletions(-) create mode 100644 hive-matrix-mcp/src/handlers_mock_tests.rs diff --git a/Cargo.lock b/Cargo.lock index c14049f1e..26af1106a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,6 +135,15 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "ar_archive_writer" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523e5e187fff36fcb8d1d19ccf0ca4ca43ec3d158316057f66dc6f72716bc5ec" +dependencies = [ + "object", +] + [[package]] name = "archery" version = "1.2.3" @@ -156,6 +165,28 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbc3a507a82b17ba0d98f6ce8fd6954ea0c8152e98009d36a40d8dcc8ce078a" +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "assert_matches2" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b220e7e9afc9b4ebf03f061f1a3f8e09a8aeee303bfab530bff54cfdfe311d6" + [[package]] name = "assign" version = "1.1.1" @@ -470,6 +501,12 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7354288c522e7e980fafd2075d63d1285794c3a6a16cdd492f189ea406e5f18b" +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cbc" version = "0.1.2" @@ -843,6 +880,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ctor" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" +dependencies = [ + "quote", + "syn 2.0.119", +] + [[package]] name = "ctr" version = "0.9.2" @@ -970,16 +1017,34 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c03c416ed1a30fbb027ef484ba6ab6f80e1eada675e1a2b92fd673c045a1f1d" +[[package]] +name = "deadpool" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0be2b1d1d6ec8d846f05e137292d0b89133caf95ef33695424c09568bdd39b1b" +dependencies = [ + "deadpool-runtime 0.1.4", + "lazy_static", + "num_cpus", + "tokio", +] + [[package]] name = "deadpool" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e98a7e119cd347f4201e1159b19831029e203e2d8b790547708e8157b4acf1e" dependencies = [ - "deadpool-runtime", + "deadpool-runtime 0.3.1", "tokio", ] +[[package]] +name = "deadpool-runtime" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" + [[package]] name = "deadpool-runtime" version = "0.3.1" @@ -995,7 +1060,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e385cc95d3d582c328b36d1ff90feac061102b001894b555e6b465a2e0eaabbf" dependencies = [ - "deadpool-runtime", + "deadpool-runtime 0.3.1", ] [[package]] @@ -1985,6 +2050,7 @@ dependencies = [ "hive-sock-client", "matrix-sdk", "matrix-sdk-base", + "matrix-sdk-test", "mime", "mime_guess", "reqwest", @@ -2560,6 +2626,21 @@ dependencies = [ "generic-array", ] +[[package]] +name = "insta" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67d3d2e287e4b86c10b3f3b641033d1f89b74bdb39d05f34952e2b9a6fe21cd" +dependencies = [ + "console", + "once_cell", + "pest", + "pest_derive", + "serde", + "similar", + "tempfile", +] + [[package]] name = "ipnet" version = "2.12.2" @@ -2712,6 +2793,12 @@ version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + [[package]] name = "libsqlite3-sys" version = "0.35.0" @@ -2925,6 +3012,7 @@ dependencies = [ "anymap2", "aquamarine", "as_variant", + "assert_matches2", "async-channel", "async-once-cell", "async-stream", @@ -2949,6 +3037,7 @@ dependencies = [ "matrix-sdk-common", "matrix-sdk-indexeddb", "matrix-sdk-sqlite", + "matrix-sdk-test", "mime", "mime2ext", "oauth2", @@ -2974,6 +3063,7 @@ dependencies = [ "urlencoding", "vodozemac", "webpki-roots 1.0.11", + "wiremock", "zeroize", ] @@ -2984,6 +3074,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e09a917eb1f7643d9d9a06b2f131e2ceb39df6910a7b830dac18bfd6db37a1f5" dependencies = [ "as_variant", + "assert_matches", + "assert_matches2", "async-trait", "bitflags", "decancer", @@ -2991,9 +3083,11 @@ dependencies = [ "eyeball-im", "futures-util", "growable-bloom-filter", + "http", "matrix-sdk-common", "matrix-sdk-crypto", "matrix-sdk-store-encryption", + "matrix-sdk-test", "regex", "ruma", "serde", @@ -3050,6 +3144,7 @@ dependencies = [ "itertools 0.14.0", "js_option", "matrix-sdk-common", + "matrix-sdk-test", "pbkdf2", "rand 0.10.3", "rmp-serde", @@ -3109,7 +3204,7 @@ checksum = "a49133429271005745f8d5a05362d2ba6567274777250236799927ca30dc0670" dependencies = [ "as_variant", "async-trait", - "deadpool", + "deadpool 0.13.1", "deadpool-sync", "itertools 0.14.0", "matrix-sdk-base", @@ -3151,6 +3246,40 @@ dependencies = [ "zeroize", ] +[[package]] +name = "matrix-sdk-test" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8023d4315fff35598c2d4a955920c1273c6aaab4dcd9ed405238a882581649bf" +dependencies = [ + "as_variant", + "ctor", + "getrandom 0.4.3", + "http", + "insta", + "matrix-sdk-common", + "matrix-sdk-test-macros", + "ruma", + "serde", + "serde_json", + "sha2 0.10.9", + "tokio", + "tracing-subscriber", + "vodozemac", + "wasm-bindgen-test", + "wiremock", +] + +[[package]] +name = "matrix-sdk-test-macros" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97d6a0e5b1401c530b3c5d18cb98257d255d396bacf3903beda6718a2f4c4c5" +dependencies = [ + "quote", + "syn 2.0.119", +] + [[package]] name = "matrix_indexed_db_futures" version = "0.7.0" @@ -3233,6 +3362,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "minicov" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4869b6a491569605d66d3952bcdf03df789e5b536e5f0cf7758a7f08a55ae24d" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "minijinja" version = "2.24.0" @@ -3353,6 +3492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -3394,6 +3534,15 @@ dependencies = [ "reqwest", ] +[[package]] +name = "object" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.21.4" @@ -3406,6 +3555,12 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -3564,6 +3719,59 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "pest" +version = "2.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ec53fd1d256900a9a771bf2720d42cef6f8bc91b4e25065fbd291e3e7222576" +dependencies = [ + "memchr", + "pest_stack_guard", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf794fd301ddc20818a6b4de85ed507f4b45300245cec948982e69e12e3bd7" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3073afae5db334c25dea9fc3e230a4f191e920c1df080cb9c0b37c9ce1dbb41" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "pest_meta" +version = "2.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bc7f614b3742541642af1685faaa910bf6333e3cd3729c2cccd118146a57327" +dependencies = [ + "pest", +] + +[[package]] +name = "pest_stack_guard" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ac6154fd4418b8f0b82532c59c26f303f9ca59a64c883e8ce3971fd82733439" +dependencies = [ + "psm", + "stacker", +] + [[package]] name = "petgraph" version = "0.8.3" @@ -3820,6 +4028,16 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "psm" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd034599e63b970727f70d79e02d62390a4a84f7c6b827c27c46d5ac3fa622" +dependencies = [ + "ar_archive_writer", + "cc", +] + [[package]] name = "pulldown-cmark" version = "0.13.6" @@ -4963,6 +5181,19 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +[[package]] +name = "stacker" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707f49d46706bacf8a2b00d51dace3f9de527c13eec3778f570c411f89e69967" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys 0.61.2", +] + [[package]] name = "string_cache" version = "0.9.0" @@ -5988,6 +6219,12 @@ version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "214ca0b2191785cbc06209b9ca1861e048e39b5ba33574b3cedd58363d5bb5f6" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "ulid" version = "1.2.1" @@ -6310,6 +6547,44 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-bindgen-test" +version = "0.3.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4913c0ade07e01ab574b20d2741538f070efa12cb7a1a1e2d5df6ea41cf522" +dependencies = [ + "cast", + "js-sys", + "libm", + "minicov", + "nu-ansi-term", + "num-traits", + "oorandom", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", + "wasm-bindgen-test-shared", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238071aa4c5b268e57d21018621a2e2403c29dd11c55dbdf790ed47fdb9241c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "wasm-bindgen-test-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab365ce29ba0232367502b2894556ae77a9c214d33dbf453fdba7f586905918" + [[package]] name = "wasm-streams" version = "0.5.0" @@ -6599,6 +6874,29 @@ dependencies = [ "memchr", ] +[[package]] +name = "wiremock" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08db1edfb05d9b3c1542e521aea074442088292f00b5f28e435c714a98f85031" +dependencies = [ + "assert-json-diff", + "base64 0.22.1", + "deadpool 0.12.3", + "futures", + "http", + "http-body-util", + "hyper", + "hyper-util", + "log", + "once_cell", + "regex", + "serde", + "serde_json", + "tokio", + "url", +] + [[package]] name = "wit-bindgen" version = "0.57.1" diff --git a/hive-matrix-mcp/Cargo.toml b/hive-matrix-mcp/Cargo.toml index 96bd9cb72..4c2234844 100644 --- a/hive-matrix-mcp/Cargo.toml +++ b/hive-matrix-mcp/Cargo.toml @@ -40,4 +40,7 @@ path = "src/main.rs" [dev-dependencies] tempfile = "3" +# The SDK's own mock homeserver (`matrix_sdk::test_utils::mocks`), for the handler tests. +matrix-sdk = { workspace = true, features = ["testing"] } +matrix-sdk-test = "0.18" tokio = { workspace = true, features = ["test-util"] } diff --git a/hive-matrix-mcp/src/handlers.rs b/hive-matrix-mcp/src/handlers.rs index 0e840f412..09e25b365 100644 --- a/hive-matrix-mcp/src/handlers.rs +++ b/hive-matrix-mcp/src/handlers.rs @@ -1886,3 +1886,7 @@ mod recipient_tests { ); } } + +#[cfg(test)] +#[path = "handlers_mock_tests.rs"] +mod mock_tests; diff --git a/hive-matrix-mcp/src/handlers_mock_tests.rs b/hive-matrix-mcp/src/handlers_mock_tests.rs new file mode 100644 index 000000000..63b791fba --- /dev/null +++ b/hive-matrix-mcp/src/handlers_mock_tests.rs @@ -0,0 +1,238 @@ +//! The handlers against the SDK's own mock homeserver +//! (`matrix_sdk::test_utils::mocks`): what each one asks the server and what it +//! answers the agent, with the server's replies scripted per test. The pure +//! helpers have their own tests next to them in `handlers.rs`. + +use matrix_sdk::Client; +use matrix_sdk::ruma::api::client::receipt::create_receipt::v3::ReceiptType; +use matrix_sdk::ruma::events::AnyTimelineEvent; +use matrix_sdk::ruma::serde::Raw; +use matrix_sdk::ruma::{EventId, event_id, room_id, user_id}; +use matrix_sdk::test_utils::mocks::{MatrixMockServer, RoomMessagesResponseTemplate}; +use matrix_sdk_test::InvitedRoomBuilder; +use matrix_sdk_test::event_factory::EventFactory; +use serde_json::Value; + +use super::*; + +/// The payload of an `Ok` response, or a panic naming the error. +fn ok(response: DaemonResponse) -> Value { + match response { + DaemonResponse::Ok { payload } => payload, + DaemonResponse::Error { message } => panic!("expected ok, got error: {message}"), + } +} + +/// The message of an `Error` response, or a panic naming the payload. +fn err(response: DaemonResponse) -> String { + match response { + DaemonResponse::Error { message } => message, + DaemonResponse::Ok { payload } => panic!("expected an error, got ok: {payload}"), + } +} + +/// A client on a mock server that has joined `!room:localhost`, whose history +/// is `history` (newest first) and which is not encrypted. +async fn room_with(history: Vec>) -> (MatrixMockServer, Client) { + let server = MatrixMockServer::new().await; + let client = server.client_builder().build().await; + server + .sync_joined_room(&client, room_id!("!room:localhost")) + .await; + server.mock_room_state_encryption().plain().mount().await; + server + .mock_room_messages() + .ok(RoomMessagesResponseTemplate::default().events(history)) + .mount() + .await; + (server, client) +} + +/// [`room_with`] an empty history: the agent is caught up. +async fn caught_up_room() -> (MatrixMockServer, Client) { + room_with(Vec::new()).await +} + +/// A text message from `@bob:localhost` in `!room:localhost`. +fn bobs_message(id: &str, body: &str) -> Raw { + EventFactory::new() + .room(room_id!("!room:localhost")) + .sender(user_id!("@bob:localhost")) + .text_msg(body) + .event_id(<&EventId>::try_from(id).expect("event id")) + .into_raw_timeline() +} + +#[tokio::test] +async fn a_message_to_a_caught_up_room_is_sent() { + let (server, client) = caught_up_room().await; + server + .mock_room_send() + .ok(event_id!("$sent:localhost")) + .expect(1) + .mount() + .await; + + let got = ok(send_message(&client, "!room:localhost", "hello").await); + + assert_eq!(got["event_id"], "$sent:localhost"); + assert_eq!(got["room_id"], "!room:localhost"); +} + +#[tokio::test] +async fn a_message_from_someone_else_blocks_the_send() { + let (server, client) = room_with(vec![bobs_message("$new:localhost", "are you there?")]).await; + server + .mock_room_send() + .ok(event_id!("$x:localhost")) + .never() + .mount() + .await; + + let message = err(send_message(&client, "!room:localhost", "hello").await); + + assert!(message.contains("unread message"), "{message}"); +} + +#[tokio::test] +async fn marking_an_event_read_sends_a_read_receipt() { + let (server, client) = room_with(vec![bobs_message("$new:localhost", "hi")]).await; + server + .mock_send_receipt(ReceiptType::Read) + .ok() + .expect(1) + .mount() + .await; + + let got = ok(mark_read(&client, "!room:localhost", "$new:localhost").await); + + assert_eq!(got["marked_read"], "$new:localhost"); +} + +#[tokio::test] +async fn a_room_that_is_not_joined_or_not_a_room_is_refused() { + let (_server, client) = caught_up_room().await; + + let unknown = err(send_message(&client, "!other:localhost", "hi").await); + assert!(unknown.contains("not joined"), "{unknown}"); + let malformed = err(send_message(&client, "not a room", "hi").await); + assert!(malformed.contains("invalid room reference"), "{malformed}"); +} + +#[tokio::test] +async fn a_reaction_names_its_target_and_needs_no_catch_up() { + let (server, client) = room_with(vec![bobs_message("$new:localhost", "hi")]).await; + server + .mock_room_send() + .ok(event_id!("$reaction:localhost")) + .expect(1) + .mount() + .await; + + let got = ok(send_reaction(&client, "!room:localhost", "$new:localhost", "👍").await); + + assert_eq!(got["event_id"], "$reaction:localhost"); + assert_eq!(got["target"], "$new:localhost"); +} + +#[tokio::test] +async fn a_malformed_event_id_is_refused_before_the_server_is_asked() { + let (_server, client) = caught_up_room().await; + + for response in [ + send_reaction(&client, "!room:localhost", "nope", "👍").await, + mark_read(&client, "!room:localhost", "nope").await, + send_redact(&client, "!room:localhost", "nope", None).await, + ] { + assert!(err(response).contains("invalid event_id")); + } +} + +#[tokio::test] +async fn a_redaction_goes_to_the_server_and_names_its_target() { + let (server, client) = caught_up_room().await; + server + .mock_room_redact() + .ok(event_id!("$redaction:localhost")) + .expect(1) + .mount() + .await; + + let got = ok(send_redact(&client, "!room:localhost", "$old:localhost", Some("spam")).await); + + assert_eq!(got["event_id"], "$redaction:localhost"); + assert_eq!(got["target"], "$old:localhost"); +} + +#[tokio::test] +async fn a_server_refusal_reaches_the_agent_as_an_error() { + let (server, client) = caught_up_room().await; + server.mock_room_send().error500().mount().await; + + let message = err(send_message(&client, "!room:localhost", "hello").await); + + assert!(message.contains("send to !room:localhost"), "{message}"); +} + +#[tokio::test] +async fn the_joined_rooms_are_listed() { + let (_server, client) = caught_up_room().await; + + let got = ok(list_rooms(&client).await); + + let rooms = got.as_array().expect("a list"); + assert_eq!(rooms.len(), 1); + assert_eq!(rooms[0]["room_id"], "!room:localhost"); +} + +#[tokio::test] +async fn an_invite_is_listed_and_a_joined_room_is_not_an_invite() { + let (server, client) = caught_up_room().await; + server + .sync_room( + &client, + InvitedRoomBuilder::new(room_id!("!invited:localhost")), + ) + .await; + + let got = ok(list_invites(&client).await); + + let invites = got.as_array().expect("a list"); + assert_eq!(invites.len(), 1); + assert_eq!(invites[0]["room_id"], "!invited:localhost"); +} + +#[tokio::test] +async fn an_invite_to_a_room_is_sent_to_the_server_and_a_bad_user_is_refused() { + let (server, client) = caught_up_room().await; + server.mock_invite_user_by_id().ok().expect(1).mount().await; + + let got = ok(invite_user(&client, "!room:localhost", "@bob:localhost").await); + + assert_eq!(got["invited"], true); + assert_eq!(got["user_id"], "@bob:localhost"); + let bad = err(invite_user(&client, "!room:localhost", "bob").await); + assert!(bad.contains("invalid user_id"), "{bad}"); +} + +#[tokio::test] +async fn rejecting_an_invite_leaves_the_room() { + let (server, client) = caught_up_room().await; + server + .sync_room( + &client, + InvitedRoomBuilder::new(room_id!("!invited:localhost")), + ) + .await; + server + .mock_room_leave() + .ok(room_id!("!invited:localhost")) + .expect(1) + .mount() + .await; + + let got = ok(resolve_invite(&client, "!invited:localhost", InviteAction::Reject).await); + + assert_eq!(got["rejected"], true); + assert_eq!(got["room_id"], "!invited:localhost"); +}