Skip to content

Commit 4321d1b

Browse files
committed
refactor: 'TransactionsImporter' does not return transactions in signer
1 parent 0008baf commit 4321d1b

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

mithril-signer/src/cardano_transactions_importer.rs

Lines changed: 13 additions & 15 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

@@ -619,24 +613,28 @@ 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();
624616

625-
CardanoTransactionsImporter::new_for_test(
617+
let (importer, repository) = {
618+
let connection = Arc::new(cardano_tx_db_connection().unwrap());
619+
let repository = Arc::new(CardanoTransactionRepository::new(connection.clone()));
620+
let importer = CardanoTransactionsImporter::new_for_test(
626621
Arc::new(DumbBlockScanner::new(blocks.clone())),
627-
Arc::new(CardanoTransactionRepository::new(Arc::new(connection))),
628-
)
622+
Arc::new(CardanoTransactionRepository::new(connection.clone())),
623+
);
624+
(importer, repository)
629625
};
630626

631-
let cold_imported_transactions = importer
627+
importer
632628
.import(12)
633629
.await
634630
.expect("Transactions Importer should succeed");
631+
let cold_imported_transactions = repository.get_all().await.unwrap();
635632

636-
let warm_imported_transactions = importer
633+
importer
637634
.import(12)
638635
.await
639636
.expect("Transactions Importer should succeed");
637+
let warm_imported_transactions = repository.get_all().await.unwrap();
640638

641639
assert_eq!(transactions, cold_imported_transactions);
642640
assert_eq!(cold_imported_transactions, warm_imported_transactions);

0 commit comments

Comments
 (0)