diff --git a/src/db/resolver.rs b/src/db/resolver.rs index 7429c87..1ca502d 100644 --- a/src/db/resolver.rs +++ b/src/db/resolver.rs @@ -256,23 +256,32 @@ pub async fn list_active_indexers( #[cfg(test)] mod tests { + use crate::message_types::PublicPoiMessage; + use super::*; - use serde_json::json; + + use sqlx::PgPool; + + + async fn insert_test_data(pool: &PgPool, entries: Vec<(i64, &str)>) { for (nonce, graph_account) in entries { - let message = json!({ - "nonce": nonce, - "graph_account": graph_account - }); - - sqlx::query!("INSERT INTO messages (message) VALUES ($1)", message) - .execute(pool) - .await - .expect("Failed to insert test data"); + let message = PublicPoiMessage { + identifier: "Qm123".to_string(), + content: "text".to_string(), + nonce: nonce.try_into().unwrap(), + network: "text".to_string(), + block_number: 1, + block_hash: "hash".to_string(), + graph_account: graph_account.to_string(), + }; + + add_message(pool, message).await.expect("Failed to insert test data"); } } + #[sqlx::test(migrations = "./migrations")] async fn test_list_active_indexers_without_indexers(pool: PgPool) {