Skip to content

Commit

Permalink
chore(event cache store): remove failing test
Browse files Browse the repository at this point in the history
Because the latest migration would clear events to-be-sent from the send
queue, the test now failed. It's been considered OK.
  • Loading branch information
bnjbvr committed Oct 31, 2024
1 parent e810408 commit e08d961
Showing 1 changed file with 3 additions and 83 deletions.
86 changes: 3 additions & 83 deletions crates/matrix-sdk-sqlite/src/state_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2010,21 +2010,12 @@ mod migration_tests {
},
};

use assert_matches::assert_matches;
use matrix_sdk_base::{
store::{QueueWedgeError, SerializableEventContent},
sync::UnreadNotificationsCount,
RoomState, StateStore,
};
use matrix_sdk_base::{sync::UnreadNotificationsCount, RoomState, StateStore};
use matrix_sdk_test::async_test;
use once_cell::sync::Lazy;
use ruma::{
events::{
room::{create::RoomCreateEventContent, message::RoomMessageEventContent},
StateEventType,
},
room_id, server_name, user_id, EventId, MilliSecondsSinceUnixEpoch, RoomId, TransactionId,
UserId,
events::{room::create::RoomCreateEventContent, StateEventType},
room_id, server_name, user_id, EventId, MilliSecondsSinceUnixEpoch, RoomId, UserId,
};
use rusqlite::Transaction;
use serde_json::json;
Expand Down Expand Up @@ -2271,75 +2262,4 @@ mod migration_tests {
assert_eq!(room_c.name(), None);
assert_eq!(room_c.creator(), Some(room_c_create_sender));
}

#[async_test]
pub async fn test_migrating_v7_to_v8() {
let path = new_path();

let room_a_id = room_id!("!room_a:dummy.local");
let wedged_event_transaction_id = TransactionId::new();
let local_event_transaction_id = TransactionId::new();

// Create and populate db.
{
let db = create_fake_db(&path, 7).await.unwrap();
let conn = db.pool.get().await.unwrap();

let wedge_tx = wedged_event_transaction_id.clone();
let local_tx = local_event_transaction_id.clone();

conn.with_transaction(move |txn| {
add_send_queue_event_v7(&db, txn, &wedge_tx, room_a_id, true)?;
add_send_queue_event_v7(&db, txn, &local_tx, room_a_id, false)?;

Result::<_, Error>::Ok(())
})
.await
.unwrap();
}

// This transparently migrates to the latest version.
let store = SqliteStateStore::open(path, Some(SECRET)).await.unwrap();
let requests = store.load_send_queue_requests(room_a_id).await.unwrap();

assert_eq!(requests.len(), 2);

let migrated_wedged =
requests.iter().find(|e| e.transaction_id == wedged_event_transaction_id).unwrap();

assert!(migrated_wedged.is_wedged());
assert_matches!(
migrated_wedged.error.clone(),
Some(QueueWedgeError::GenericApiError { .. })
);

let migrated_ok = requests
.iter()
.find(|e| e.transaction_id == local_event_transaction_id.clone())
.unwrap();

assert!(!migrated_ok.is_wedged());
assert!(migrated_ok.error.is_none());
}

fn add_send_queue_event_v7(
this: &SqliteStateStore,
txn: &Transaction<'_>,
transaction_id: &TransactionId,
room_id: &RoomId,
is_wedged: bool,
) -> Result<(), Error> {
let content =
SerializableEventContent::new(&RoomMessageEventContent::text_plain("Hello").into())?;

let room_id_key = this.encode_key(keys::SEND_QUEUE, room_id);
let room_id_value = this.serialize_value(&room_id.to_owned())?;

let content = this.serialize_json(&content)?;

txn.prepare_cached("INSERT INTO send_queue_events (room_id, room_id_val, transaction_id, content, wedged) VALUES (?, ?, ?, ?, ?)")?
.execute((room_id_key, room_id_value, transaction_id.to_string(), content, is_wedged))?;

Ok(())
}
}

0 comments on commit e08d961

Please sign in to comment.