@@ -92,89 +92,16 @@ impl<G: CommitmentCurve> FieldBlob<G> {
9292 }
9393}
9494
95- #[ cfg( test) ]
96- pub mod test_utils {
97- use proptest:: prelude:: * ;
98-
99- #[ derive( Debug ) ]
100- pub struct BlobData ( pub Vec < u8 > ) ;
101-
102- #[ derive( Clone , Debug ) ]
103- pub enum DataSize {
104- Small ,
105- Medium ,
106- Large ,
107- }
108-
109- impl DataSize {
110- const KB : usize = 1_000 ;
111- const MB : usize = 1_000_000 ;
112-
113- fn size_range_bytes ( & self ) -> ( usize , usize ) {
114- match self {
115- // Small: 1KB - 1MB
116- Self :: Small => ( Self :: KB , Self :: MB ) ,
117- // Medium: 1MB - 10MB
118- Self :: Medium => ( Self :: MB , 10 * Self :: MB ) ,
119- // Large: 10MB - 100MB
120- Self :: Large => ( 10 * Self :: MB , 100 * Self :: MB ) ,
121- }
122- }
123- }
124-
125- impl Arbitrary for DataSize {
126- type Parameters = ( ) ;
127- type Strategy = BoxedStrategy < Self > ;
128-
129- fn arbitrary_with ( _: ( ) ) -> Self :: Strategy {
130- prop_oneof ! [
131- 6 => Just ( DataSize :: Small ) , // 60% chance
132- 3 => Just ( DataSize :: Medium ) ,
133- 1 => Just ( DataSize :: Large )
134- ]
135- . boxed ( )
136- }
137- }
138-
139- impl Default for DataSize {
140- fn default ( ) -> Self {
141- Self :: Small
142- }
143- }
144-
145- impl Arbitrary for BlobData {
146- type Parameters = DataSize ;
147- type Strategy = BoxedStrategy < Self > ;
148-
149- fn arbitrary ( ) -> Self :: Strategy {
150- DataSize :: arbitrary ( )
151- . prop_flat_map ( |size| {
152- let ( min, max) = size. size_range_bytes ( ) ;
153- prop:: collection:: vec ( any :: < u8 > ( ) , min..max)
154- } )
155- . prop_map ( BlobData )
156- . boxed ( )
157- }
158-
159- fn arbitrary_with ( size : Self :: Parameters ) -> Self :: Strategy {
160- let ( min, max) = size. size_range_bytes ( ) ;
161- prop:: collection:: vec ( any :: < u8 > ( ) , min..max)
162- . prop_map ( BlobData )
163- . boxed ( )
164- }
165- }
166- }
167-
16895#[ cfg( test) ]
16996mod tests {
17097 use crate :: { commitment:: commit_to_field_elems, env} ;
17198
17299 use super :: * ;
100+ use crate :: utils:: test_utils:: * ;
173101 use ark_poly:: Radix2EvaluationDomain ;
174102 use mina_curves:: pasta:: { Fp , Vesta } ;
175103 use once_cell:: sync:: Lazy ;
176104 use proptest:: prelude:: * ;
177- use test_utils:: * ;
178105
179106 static SRS : Lazy < SRS < Vesta > > = Lazy :: new ( || {
180107 if let Ok ( srs) = std:: env:: var ( "SRS_FILEPATH" ) {
@@ -191,7 +118,7 @@ mod tests {
191118 proptest ! {
192119 #![ proptest_config( ProptestConfig :: with_cases( 20 ) ) ]
193120 #[ test]
194- fn test_round_trip_blob_encoding( BlobData ( xs) in BlobData :: arbitrary( ) )
121+ fn test_round_trip_blob_encoding( UserData ( xs) in UserData :: arbitrary( ) )
195122 { let blob = FieldBlob :: <Vesta >:: encode( & * SRS , * DOMAIN , & xs) ;
196123 let bytes = rmp_serde:: to_vec( & blob) . unwrap( ) ;
197124 let a = rmp_serde:: from_slice( & bytes) . unwrap( ) ;
@@ -206,7 +133,7 @@ mod tests {
206133 proptest ! {
207134 #![ proptest_config( ProptestConfig :: with_cases( 10 ) ) ]
208135 #[ test]
209- fn test_user_and_storage_provider_commitments_equal( BlobData ( xs) in BlobData :: arbitrary( ) )
136+ fn test_user_and_storage_provider_commitments_equal( UserData ( xs) in UserData :: arbitrary( ) )
210137 { let elems = encode_for_domain( & * DOMAIN , & xs) ;
211138 let user_commitments = commit_to_field_elems( & * SRS , * DOMAIN , elems) ;
212139 let blob = FieldBlob :: <Vesta >:: encode( & * SRS , * DOMAIN , & xs) ;
0 commit comments