From edb13e9021742a7aac0c5569fd2c0416e966ec19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Tr=C4=85d?= Date: Wed, 19 Jun 2024 13:43:44 +0200 Subject: [PATCH] Fix invalid condition grouping (#50) --- src/db.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/db.rs b/src/db.rs index f27db80..de8c2c3 100644 --- a/src/db.rs +++ b/src/db.rs @@ -915,7 +915,7 @@ impl Database { LEFT JOIN sent_transactions s ON t.id = s.tx_id LEFT JOIN tx_hashes h ON s.valid_tx_hash = h.tx_hash WHERE t.relayer_id = $1 - AND ($2 = true AND s.status = $3) OR $2 = false + AND (($2 = true AND s.status = $3) OR $2 = false) "#, ) .bind(relayer_id) @@ -1726,6 +1726,12 @@ mod tests { let tx = db.read_relayer_tx(relayer_2_id, tx_id).await?; assert!(tx.is_none(), "Tx cannot be read by relayer 2"); + let txs = db.read_relayer_txs(relayer_2_id, None).await?; + assert!(txs.is_empty(), "Txs cannot be read by relayer 2"); + + let txs = db.read_relayer_txs(relayer_1_id, None).await?; + assert_eq!(txs.len(), 1, "Txs can be read by relayer 1"); + Ok(()) }