Skip to content

Commit 9b84544

Browse files
committed
Reduce number of cfg(test) directive in cardano transactions repositories
By reusing the existing 'test extension' module.
1 parent 599ac48 commit 9b84544

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

mithril-aggregator/src/database/repository/cardano_transaction_repository.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ use crate::database::provider::{
2222
use crate::database::record::{BlockRangeRootRecord, CardanoTransactionRecord};
2323
use crate::services::{TransactionStore, TransactionsRetriever};
2424

25-
#[cfg(test)]
26-
use mithril_persistence::sqlite::GetAllProvider;
27-
2825
/// ## Cardano transaction repository
2926
///
3027
/// This is a business oriented layer to perform actions on the database through
@@ -193,14 +190,6 @@ impl CardanoTransactionRepository {
193190

194191
Ok(Box::new(iterator))
195192
}
196-
197-
#[cfg(test)]
198-
pub(crate) async fn get_all(&self) -> StdResult<Vec<CardanoTransaction>> {
199-
let provider = GetCardanoTransactionProvider::new(&self.connection);
200-
let records = provider.get_all()?;
201-
202-
Ok(records.map(|record| record.into()).collect())
203-
}
204193
}
205194

206195
#[cfg(test)]
@@ -212,6 +201,13 @@ pub mod test_extensions {
212201
use super::*;
213202

214203
impl CardanoTransactionRepository {
204+
pub async fn get_all(&self) -> StdResult<Vec<CardanoTransaction>> {
205+
let provider = GetCardanoTransactionProvider::new(&self.connection);
206+
let records = provider.get_all()?;
207+
208+
Ok(records.map(|record| record.into()).collect())
209+
}
210+
215211
pub fn get_all_block_range_root(&self) -> StdResult<Vec<BlockRangeRootRecord>> {
216212
let provider = GetBlockRangeRootProvider::new(&self.connection);
217213
let records = provider.get_all()?;

mithril-signer/src/database/repository/cardano_transaction_repository.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ use crate::database::provider::{
2222
use crate::database::record::{BlockRangeRootRecord, CardanoTransactionRecord};
2323
use crate::TransactionStore;
2424

25-
#[cfg(test)]
26-
use mithril_persistence::sqlite::GetAllProvider;
27-
2825
/// ## Cardano transaction repository
2926
///
3027
/// This is a business oriented layer to perform actions on the database through
@@ -173,14 +170,6 @@ impl CardanoTransactionRepository {
173170

174171
Ok(Box::new(iterator))
175172
}
176-
177-
#[cfg(test)]
178-
pub(crate) async fn get_all(&self) -> StdResult<Vec<CardanoTransaction>> {
179-
let provider = GetCardanoTransactionProvider::new(&self.connection);
180-
let records = provider.get_all()?;
181-
182-
Ok(records.map(|record| record.into()).collect())
183-
}
184173
}
185174

186175
#[cfg(test)]
@@ -192,6 +181,13 @@ pub mod test_extensions {
192181
use super::*;
193182

194183
impl CardanoTransactionRepository {
184+
pub async fn get_all(&self) -> StdResult<Vec<CardanoTransaction>> {
185+
let provider = GetCardanoTransactionProvider::new(&self.connection);
186+
let records = provider.get_all()?;
187+
188+
Ok(records.map(|record| record.into()).collect())
189+
}
190+
195191
pub fn get_all_block_range_root(&self) -> StdResult<Vec<BlockRangeRootRecord>> {
196192
let provider = GetBlockRangeRootProvider::new(&self.connection);
197193
let records = provider.get_all()?;

0 commit comments

Comments
 (0)