@@ -52,6 +52,10 @@ fn digest_point(point: RistrettoPoint) -> [u8; 32] {
5252 out
5353}
5454
55+ fn inclusive_upper_bound ( range : & std:: ops:: Range < u32 > ) -> u32 {
56+ range. end . saturating_sub ( 1 )
57+ }
58+
5559impl UserState {
5660 #[ instrument( skip(
5761 self ,
@@ -148,9 +152,9 @@ impl UserState {
148152 New . measurement_count = Some ( ( measurement_count + 1 ) . into ( ) ) ;
149153 let params = submit:: Params {
150154 min_age_today : age_range. start . into ( ) ,
151- max_age : age_range. end . into ( ) ,
155+ max_age : inclusive_upper_bound ( & age_range) . into ( ) ,
152156 min_measurement_count : measurement_count_range. start . into ( ) ,
153- max_measurement_count : measurement_count_range. end . into ( ) ,
157+ max_measurement_count : inclusive_upper_bound ( & measurement_count_range) . into ( ) ,
154158 DOMAIN ,
155159 NYM ,
156160 } ;
@@ -232,9 +236,9 @@ impl ServerState {
232236
233237 let params = submit:: Params {
234238 min_age_today : age_range. start . into ( ) ,
235- max_age : age_range. end . into ( ) ,
239+ max_age : inclusive_upper_bound ( & age_range) . into ( ) ,
236240 min_measurement_count : measurement_count_range. start . into ( ) ,
237- max_measurement_count : measurement_count_range. end . into ( ) ,
241+ max_measurement_count : inclusive_upper_bound ( & measurement_count_range) . into ( ) ,
238242 DOMAIN ,
239243 NYM : nym_point,
240244 } ;
@@ -303,6 +307,12 @@ mod tests {
303307 ) ;
304308 }
305309
310+ #[ test]
311+ fn test_inclusive_upper_bound ( ) {
312+ assert_eq ! ( inclusive_upper_bound( & ( 10 ..11 ) ) , 10 ) ;
313+ assert_eq ! ( inclusive_upper_bound( & ( 0 ..1 ) ) , 0 ) ;
314+ }
315+
306316 #[ test]
307317 fn test_submit_request ( ) {
308318 let rng = & mut rand:: thread_rng ( ) ;
0 commit comments