@@ -180,19 +180,9 @@ impl CardanoTransactionsProofsMessage {
180
180
181
181
#[ cfg( test) ]
182
182
mod tests {
183
- use std:: { path:: Path , sync:: Arc } ;
184
-
185
- use slog:: Logger ;
186
183
187
184
use super :: * ;
188
- use crate :: {
189
- cardano_transaction_parser:: DumbTransactionParser ,
190
- crypto_helper:: MKProof ,
191
- entities:: { Beacon , CardanoTransaction } ,
192
- signable_builder:: {
193
- CardanoTransactionsSignableBuilder , MockTransactionStore , SignableBuilder ,
194
- } ,
195
- } ;
185
+ use crate :: crypto_helper:: MKProof ;
196
186
197
187
#[ test]
198
188
fn verify_malformed_proofs_fail ( ) {
@@ -322,77 +312,90 @@ mod tests {
322
312
) ;
323
313
}
324
314
325
- #[ tokio:: test]
326
- async fn verify_hashes_from_verified_cardano_transaction_and_from_signable_builder_are_equals ( )
327
- {
328
- let transactions = vec ! [
329
- CardanoTransaction :: new( "tx-hash-123" , 1 , 1 ) ,
330
- CardanoTransaction :: new( "tx-hash-456" , 2 , 1 ) ,
331
- ] ;
332
-
333
- assert_eq ! (
334
- from_verified_cardano_transaction( & transactions, 99999 ) . compute_hash( ) ,
335
- from_signable_builder( & transactions, 99999 )
336
- . await
337
- . compute_hash( )
338
- ) ;
339
-
340
- assert_ne ! (
341
- from_verified_cardano_transaction( & transactions, 99999 ) . compute_hash( ) ,
342
- from_signable_builder( & transactions, 123456 )
343
- . await
344
- . compute_hash( )
345
- ) ;
346
- }
347
-
348
- fn from_verified_cardano_transaction (
349
- transactions : & [ CardanoTransaction ] ,
350
- immutable_file_number : u64 ,
351
- ) -> ProtocolMessage {
352
- let set_proof = CardanoTransactionsSetProof :: from_leaves (
353
- transactions
354
- . iter ( )
355
- . map ( |t| ( t. block_number , t. transaction_hash . clone ( ) ) )
356
- . collect :: < Vec < _ > > ( )
357
- . as_slice ( ) ,
358
- )
359
- . unwrap ( ) ;
360
-
361
- let verified_transactions_fake = VerifiedCardanoTransactions {
362
- certificate_hash : "whatever" . to_string ( ) ,
363
- merkle_root : set_proof. merkle_root ( ) ,
364
- certified_transactions : set_proof. transactions_hashes ( ) . to_vec ( ) ,
365
- latest_immutable_file_number : immutable_file_number,
315
+ #[ cfg( feature = "fs" ) ]
316
+ mod fs_only {
317
+ use crate :: cardano_transaction_parser:: DumbTransactionParser ;
318
+ use crate :: entities:: { Beacon , CardanoTransaction } ;
319
+ use crate :: signable_builder:: {
320
+ CardanoTransactionsSignableBuilder , MockTransactionStore , SignableBuilder ,
366
321
} ;
322
+ use slog:: Logger ;
323
+ use std:: { path:: Path , sync:: Arc } ;
324
+
325
+ use super :: * ;
326
+
327
+ #[ tokio:: test]
328
+ async fn verify_hashes_from_verified_cardano_transaction_and_from_signable_builder_are_equals (
329
+ ) {
330
+ let transactions = vec ! [
331
+ CardanoTransaction :: new( "tx-hash-123" , 1 , 1 ) ,
332
+ CardanoTransaction :: new( "tx-hash-456" , 2 , 1 ) ,
333
+ ] ;
334
+
335
+ assert_eq ! (
336
+ from_verified_cardano_transaction( & transactions, 99999 ) . compute_hash( ) ,
337
+ from_signable_builder( & transactions, 99999 )
338
+ . await
339
+ . compute_hash( )
340
+ ) ;
341
+
342
+ assert_ne ! (
343
+ from_verified_cardano_transaction( & transactions, 99999 ) . compute_hash( ) ,
344
+ from_signable_builder( & transactions, 123456 )
345
+ . await
346
+ . compute_hash( )
347
+ ) ;
348
+ }
367
349
368
- let mut message = ProtocolMessage :: new ( ) ;
369
- verified_transactions_fake. fill_protocol_message ( & mut message) ;
370
-
371
- message
372
- }
350
+ fn from_verified_cardano_transaction (
351
+ transactions : & [ CardanoTransaction ] ,
352
+ immutable_file_number : u64 ,
353
+ ) -> ProtocolMessage {
354
+ let set_proof = CardanoTransactionsSetProof :: from_leaves (
355
+ transactions
356
+ . iter ( )
357
+ . map ( |t| ( t. block_number , t. transaction_hash . clone ( ) ) )
358
+ . collect :: < Vec < _ > > ( )
359
+ . as_slice ( ) ,
360
+ )
361
+ . unwrap ( ) ;
362
+
363
+ let verified_transactions_fake = VerifiedCardanoTransactions {
364
+ certificate_hash : "whatever" . to_string ( ) ,
365
+ merkle_root : set_proof. merkle_root ( ) ,
366
+ certified_transactions : set_proof. transactions_hashes ( ) . to_vec ( ) ,
367
+ latest_immutable_file_number : immutable_file_number,
368
+ } ;
369
+
370
+ let mut message = ProtocolMessage :: new ( ) ;
371
+ verified_transactions_fake. fill_protocol_message ( & mut message) ;
372
+
373
+ message
374
+ }
373
375
374
- async fn from_signable_builder (
375
- transactions : & [ CardanoTransaction ] ,
376
- immutable_file_number : u64 ,
377
- ) -> ProtocolMessage {
378
- let mut mock_transaction_store = MockTransactionStore :: new ( ) ;
379
- mock_transaction_store
380
- . expect_store_transactions ( )
381
- . returning ( |_| Ok ( ( ) ) )
382
- . times ( 1 ) ;
383
-
384
- let cardano_transaction_signable_builder = CardanoTransactionsSignableBuilder :: new (
385
- Arc :: new ( DumbTransactionParser :: new ( transactions. to_vec ( ) ) ) ,
386
- Arc :: new ( mock_transaction_store) ,
387
- Path :: new ( "/tmp" ) ,
388
- Logger :: root ( slog:: Discard , slog:: o!( ) ) ,
389
- ) ;
390
- cardano_transaction_signable_builder
391
- . compute_protocol_message ( Beacon {
392
- immutable_file_number,
393
- ..Beacon :: default ( )
394
- } )
395
- . await
396
- . unwrap ( )
376
+ async fn from_signable_builder (
377
+ transactions : & [ CardanoTransaction ] ,
378
+ immutable_file_number : u64 ,
379
+ ) -> ProtocolMessage {
380
+ let mut mock_transaction_store = MockTransactionStore :: new ( ) ;
381
+ mock_transaction_store
382
+ . expect_store_transactions ( )
383
+ . returning ( |_| Ok ( ( ) ) )
384
+ . times ( 1 ) ;
385
+
386
+ let cardano_transaction_signable_builder = CardanoTransactionsSignableBuilder :: new (
387
+ Arc :: new ( DumbTransactionParser :: new ( transactions. to_vec ( ) ) ) ,
388
+ Arc :: new ( mock_transaction_store) ,
389
+ Path :: new ( "/tmp" ) ,
390
+ Logger :: root ( slog:: Discard , slog:: o!( ) ) ,
391
+ ) ;
392
+ cardano_transaction_signable_builder
393
+ . compute_protocol_message ( Beacon {
394
+ immutable_file_number,
395
+ ..Beacon :: default ( )
396
+ } )
397
+ . await
398
+ . unwrap ( )
399
+ }
397
400
}
398
401
}
0 commit comments