@@ -885,8 +885,8 @@ mod test {
885885
886886 #[ test]
887887 fn test_batch_size_limit_enforcement_with_real_sp1_proofs ( ) {
888- use aligned_sdk:: communication:: serialization:: cbor_serialize;
889888 use aligned_sdk:: common:: types:: VerificationData ;
889+ use aligned_sdk:: communication:: serialization:: cbor_serialize;
890890 use std:: fs;
891891
892892 let proof_generator_addr = Address :: random ( ) ;
@@ -934,7 +934,7 @@ mod test {
934934 for i in 0 ..10 {
935935 let sender_addr = Address :: random ( ) ;
936936 let nonce = U256 :: from ( i + 1 ) ;
937-
937+
938938 let nonced_verification_data = NoncedVerificationData :: new (
939939 verification_data. clone ( ) ,
940940 nonce,
@@ -957,14 +957,15 @@ mod test {
957957 // Test with a 5MB batch size limit
958958 let batch_size_limit = 5_000_000 ; // 5MB
959959 let gas_price = U256 :: from ( 1 ) ;
960-
960+
961961 let finalized_batch = try_build_batch (
962962 batch_queue. clone ( ) ,
963963 gas_price,
964964 batch_size_limit,
965965 50 , // max proof qty
966966 DEFAULT_CONSTANT_GAS_COST ,
967- ) . unwrap ( ) ;
967+ )
968+ . unwrap ( ) ;
968969
969970 // Verify the finalized batch respects the size limit
970971 let finalized_verification_data: Vec < VerificationData > = finalized_batch
@@ -976,20 +977,27 @@ mod test {
976977 let finalized_actual_size = finalized_serialized. len ( ) ;
977978
978979 // Assert the batch respects the limit
979- assert ! ( finalized_actual_size <= batch_size_limit,
980- "Finalized batch size {} exceeds limit {}" , finalized_actual_size, batch_size_limit) ;
981-
980+ assert ! (
981+ finalized_actual_size <= batch_size_limit,
982+ "Finalized batch size {} exceeds limit {}" ,
983+ finalized_actual_size,
984+ batch_size_limit
985+ ) ;
986+
982987 // Verify some entries were included (not empty batch)
983988 assert ! ( !finalized_batch. is_empty( ) , "Batch should not be empty" ) ;
984-
989+
985990 // Verify not all entries were included (some should be rejected due to size limit)
986- assert ! ( finalized_batch. len( ) < 10 , "Batch should not include all entries due to size limit" ) ;
991+ assert ! (
992+ finalized_batch. len( ) < 10 ,
993+ "Batch should not include all entries due to size limit"
994+ ) ;
987995 }
988996
989997 #[ test]
990998 fn test_cbor_size_upper_bound_accuracy ( ) {
991- use aligned_sdk:: communication:: serialization:: cbor_serialize;
992999 use aligned_sdk:: common:: types:: VerificationData ;
1000+ use aligned_sdk:: communication:: serialization:: cbor_serialize;
9931001 use std:: fs;
9941002
9951003 let proof_generator_addr = Address :: random ( ) ;
@@ -1035,7 +1043,7 @@ mod test {
10351043
10361044 // Test cbor_size_upper_bound() accuracy
10371045 let estimated_size = nonced_verification_data. cbor_size_upper_bound ( ) ;
1038-
1046+
10391047 // Compare with actual CBOR serialization of the inner VerificationData
10401048 let actual_serialized = cbor_serialize ( & verification_data) . unwrap ( ) ;
10411049 let actual_size = actual_serialized. len ( ) ;
@@ -1045,33 +1053,44 @@ mod test {
10451053 let actual_nonced_size = actual_nonced_serialized. len ( ) ;
10461054
10471055 // Verify CBOR encodes binary data efficiently (with serde_bytes fix)
1048- let raw_total = verification_data. proof . len ( ) +
1049- verification_data. vm_program_code . as_ref ( ) . unwrap ( ) . len ( ) +
1050- verification_data. pub_input . as_ref ( ) . unwrap ( ) . len ( ) ;
1051-
1056+ let raw_total = verification_data. proof . len ( )
1057+ + verification_data. vm_program_code . as_ref ( ) . unwrap ( ) . len ( )
1058+ + verification_data. pub_input . as_ref ( ) . unwrap ( ) . len ( ) ;
1059+
10521060 let cbor_efficiency_ratio = actual_size as f64 / raw_total as f64 ;
1053-
1061+
10541062 // With serde_bytes, CBOR should be very efficient (close to 1.0x)
1055- assert ! ( cbor_efficiency_ratio < 1.1 ,
1056- "CBOR serialization should be efficient with serde_bytes. Ratio: {:.3}x" ,
1057- cbor_efficiency_ratio) ;
1063+ assert ! (
1064+ cbor_efficiency_ratio < 1.1 ,
1065+ "CBOR serialization should be efficient with serde_bytes. Ratio: {:.3}x" ,
1066+ cbor_efficiency_ratio
1067+ ) ;
10581068
10591069 // Verify CBOR uses byte strings, not arrays
10601070 let proof_cbor = cbor_serialize ( & verification_data. proof ) . unwrap ( ) ;
10611071 let first_byte = proof_cbor[ 0 ] ;
10621072 let major_type = ( first_byte >> 5 ) & 0x07 ;
1063-
1064- assert_eq ! ( major_type, 2 , "Proof should be encoded as CBOR byte string (major type 2), got {}" , major_type) ;
1073+
1074+ assert_eq ! (
1075+ major_type, 2 ,
1076+ "Proof should be encoded as CBOR byte string (major type 2), got {}" ,
1077+ major_type
1078+ ) ;
10651079
10661080 // The estimation should be an upper bound
1067- assert ! ( estimated_size >= actual_size,
1068- "cbor_size_upper_bound() should be an upper bound. Estimated: {}, Actual: {}" ,
1069- estimated_size, actual_size) ;
1070-
1081+ assert ! (
1082+ estimated_size >= actual_size,
1083+ "cbor_size_upper_bound() should be an upper bound. Estimated: {}, Actual: {}" ,
1084+ estimated_size,
1085+ actual_size
1086+ ) ;
1087+
10711088 // The estimation should also be reasonable (not wildly over-estimated)
10721089 let estimation_overhead = estimated_size as f64 / actual_size as f64 ;
1073- assert ! ( estimation_overhead < 2.0 ,
1074- "Estimation should be reasonable, not wildly over-estimated. Overhead: {:.3}x" ,
1075- estimation_overhead) ;
1090+ assert ! (
1091+ estimation_overhead < 2.0 ,
1092+ "Estimation should be reasonable, not wildly over-estimated. Overhead: {:.3}x" ,
1093+ estimation_overhead
1094+ ) ;
10761095 }
10771096}
0 commit comments