Skip to content

Commit a7eeff9

Browse files
committed
refactor: 'TransactionsImporter' does not return transactions in aggregator
1 parent adae970 commit a7eeff9

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

mithril-aggregator/src/services/cardano_transactions_importer.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,9 @@ impl CardanoTransactionsImporter {
174174

175175
#[async_trait]
176176
impl TransactionsImporter for CardanoTransactionsImporter {
177-
async fn import(
178-
&self,
179-
up_to_beacon: ImmutableFileNumber,
180-
) -> StdResult<Vec<CardanoTransaction>> {
177+
async fn import(&self, up_to_beacon: ImmutableFileNumber) -> StdResult<()> {
181178
self.import_transactions(up_to_beacon).await?;
182-
self.import_block_ranges().await?;
183-
184-
let transactions = self.transaction_store.get_up_to(up_to_beacon).await?;
185-
Ok(transactions)
179+
self.import_block_ranges().await
186180
}
187181
}
188182

@@ -288,7 +282,7 @@ mod tests {
288282
.await
289283
.expect("Transactions Importer should succeed");
290284

291-
let stored_transactions = repository.get_up_to(10000).await.unwrap();
285+
let stored_transactions = repository.get_all().await.unwrap();
292286
assert_eq!(expected_transactions, stored_transactions);
293287
}
294288

@@ -410,7 +404,7 @@ mod tests {
410404
.await
411405
.expect("Transactions Importer should succeed");
412406

413-
let transactions = repository.get_up_to(10000).await.unwrap();
407+
let transactions = repository.get_all().await.unwrap();
414408
assert_eq!(vec![last_tx], transactions);
415409
}
416410

@@ -448,15 +442,15 @@ mod tests {
448442
CardanoTransactionsImporter::new_for_test(Arc::new(scanner_mock), repository.clone())
449443
};
450444

451-
let stored_transactions = repository.get_up_to(10000).await.unwrap();
445+
let stored_transactions = repository.get_all().await.unwrap();
452446
assert_eq!(stored_block.into_transactions(), stored_transactions);
453447

454448
importer
455449
.import_transactions(up_to_beacon)
456450
.await
457451
.expect("Transactions Importer should succeed");
458452

459-
let stored_transactions = repository.get_up_to(10000).await.unwrap();
453+
let stored_transactions = repository.get_all().await.unwrap();
460454
assert_eq!(expected_transactions, stored_transactions);
461455
}
462456

@@ -619,24 +613,27 @@ mod tests {
619613
ScannedBlock::new("block_hash-2", 20, 25, 12, vec!["tx_hash-3", "tx_hash-4"]),
620614
];
621615
let transactions = into_transactions(&blocks);
622-
let importer = {
623-
let connection = cardano_tx_db_connection().unwrap();
624-
625-
CardanoTransactionsImporter::new_for_test(
616+
let (importer, repository) = {
617+
let connection = Arc::new(cardano_tx_db_connection().unwrap());
618+
let repository = Arc::new(CardanoTransactionRepository::new(connection.clone()));
619+
let importer = CardanoTransactionsImporter::new_for_test(
626620
Arc::new(DumbBlockScanner::new(blocks.clone())),
627-
Arc::new(CardanoTransactionRepository::new(Arc::new(connection))),
628-
)
621+
Arc::new(CardanoTransactionRepository::new(connection.clone())),
622+
);
623+
(importer, repository)
629624
};
630625

631-
let cold_imported_transactions = importer
626+
importer
632627
.import(12)
633628
.await
634629
.expect("Transactions Importer should succeed");
630+
let cold_imported_transactions = repository.get_all().await.unwrap();
635631

636-
let warm_imported_transactions = importer
632+
importer
637633
.import(12)
638634
.await
639635
.expect("Transactions Importer should succeed");
636+
let warm_imported_transactions = repository.get_all().await.unwrap();
640637

641638
assert_eq!(transactions, cold_imported_transactions);
642639
assert_eq!(cold_imported_transactions, warm_imported_transactions);

0 commit comments

Comments
 (0)