@@ -690,6 +690,63 @@ mod tests {
690
690
) ;
691
691
}
692
692
693
+ #[ tokio:: test]
694
+ async fn repository_get_transactions_by_block_ranges ( ) {
695
+ let connection = Arc :: new ( cardano_tx_db_connection ( ) . unwrap ( ) ) ;
696
+ let repository = CardanoTransactionRepository :: new ( connection) ;
697
+
698
+ let transactions = vec ! [
699
+ CardanoTransaction :: new( "tx-hash-1" , 10 , 50 , "block-hash-1" , 99 ) ,
700
+ CardanoTransaction :: new( "tx-hash-2" , 11 , 51 , "block-hash-2" , 100 ) ,
701
+ CardanoTransaction :: new( "tx-hash-3" , 20 , 52 , "block-hash-3" , 101 ) ,
702
+ CardanoTransaction :: new( "tx-hash-4" , 31 , 53 , "block-hash-4" , 102 ) ,
703
+ CardanoTransaction :: new( "tx-hash-5" , 35 , 54 , "block-hash-5" , 103 ) ,
704
+ CardanoTransaction :: new( "tx-hash-6" , 46 , 55 , "block-hash-6" , 104 ) ,
705
+ ] ;
706
+ repository
707
+ . create_transactions ( transactions. clone ( ) )
708
+ . await
709
+ . unwrap ( ) ;
710
+
711
+ {
712
+ let transaction_result = repository
713
+ . get_by_block_ranges ( vec ! [ BlockRange :: from_block_number( 100 ) ] )
714
+ . await
715
+ . unwrap ( ) ;
716
+ assert_eq ! ( Vec :: <CardanoTransaction >:: new( ) , transaction_result) ;
717
+ }
718
+ {
719
+ let transaction_result = repository
720
+ . get_by_block_ranges ( vec ! [ BlockRange :: from_block_number( 0 ) ] )
721
+ . await
722
+ . unwrap ( ) ;
723
+ assert_eq ! ( transactions[ 0 ..=1 ] . to_vec( ) , transaction_result) ;
724
+ }
725
+ {
726
+ let transaction_result = repository
727
+ . get_by_block_ranges ( vec ! [
728
+ BlockRange :: from_block_number( 0 ) ,
729
+ BlockRange :: from_block_number( 15 ) ,
730
+ ] )
731
+ . await
732
+ . unwrap ( ) ;
733
+ assert_eq ! ( transactions[ 0 ..=2 ] . to_vec( ) , transaction_result) ;
734
+ }
735
+ {
736
+ let transaction_result = repository
737
+ . get_by_block_ranges ( vec ! [
738
+ BlockRange :: from_block_number( 0 ) ,
739
+ BlockRange :: from_block_number( 30 ) ,
740
+ ] )
741
+ . await
742
+ . unwrap ( ) ;
743
+ assert_eq ! (
744
+ [ transactions[ 0 ..=1 ] . to_vec( ) , transactions[ 3 ..=4 ] . to_vec( ) ] . concat( ) ,
745
+ transaction_result
746
+ ) ;
747
+ }
748
+ }
749
+
693
750
#[ tokio:: test]
694
751
async fn repository_store_block_range ( ) {
695
752
let connection = Arc :: new ( cardano_tx_db_connection ( ) . unwrap ( ) ) ;
0 commit comments