@@ -69,7 +69,7 @@ pub mod execute {
69
69
Limits {
70
70
max_objects : Some ( max) ,
71
71
..
72
- } if object_count as u128 > max. u128 ( ) => {
72
+ } if object_count as u128 >= max. u128 ( ) => {
73
73
Err ( BucketError :: MaxObjectsLimitExceeded . into ( ) )
74
74
}
75
75
Limits {
@@ -355,16 +355,80 @@ mod tests {
355
355
#[ test]
356
356
fn store_object_limits ( ) {
357
357
let cases = vec ! [
358
- ( BucketLimits { max_objects: Some ( 2u128 . into( ) ) , max_object_size: None , max_total_size: None , max_object_pins: None } , None ) ,
359
- ( BucketLimits { max_objects: None , max_object_size: Some ( 5u128 . into( ) ) , max_total_size: None , max_object_pins: None } , None ) ,
360
- ( BucketLimits { max_objects: None , max_object_size: None , max_total_size: Some ( 9u128 . into( ) ) , max_object_pins: None } , None ) ,
361
- ( BucketLimits { max_objects: None , max_object_size: None , max_total_size: None , max_object_pins: Some ( 1u128 . into( ) ) } , None ) ,
362
- ( BucketLimits { max_objects: Some ( 1u128 . into( ) ) , max_object_size: None , max_total_size: None , max_object_pins: None } , Some ( MaxObjectsLimitExceeded { } ) ) ,
363
- ( BucketLimits { max_objects: None , max_object_size: Some ( 4u128 . into( ) ) , max_total_size: None , max_object_pins: None } , Some ( ObjectMaxSizeLimitExceeded { } ) ) ,
364
- ( BucketLimits { max_objects: None , max_object_size: None , max_total_size: Some ( 8u128 . into( ) ) , max_object_pins: None } , Some ( BucketSizeLimitExceeded { } ) ) ,
365
- ( BucketLimits { max_objects: None , max_object_size: None , max_total_size: None , max_object_pins: Some ( 0u128 . into( ) ) } , Some ( MaxObjectPinsLimitExceeded { } ) ) ,
358
+ (
359
+ BucketLimits {
360
+ max_objects: Some ( 2u128 . into( ) ) ,
361
+ max_object_size: None ,
362
+ max_total_size: None ,
363
+ max_object_pins: None ,
364
+ } ,
365
+ None ,
366
+ ) ,
367
+ (
368
+ BucketLimits {
369
+ max_objects: None ,
370
+ max_object_size: Some ( 5u128 . into( ) ) ,
371
+ max_total_size: None ,
372
+ max_object_pins: None ,
373
+ } ,
374
+ None ,
375
+ ) ,
376
+ (
377
+ BucketLimits {
378
+ max_objects: None ,
379
+ max_object_size: None ,
380
+ max_total_size: Some ( 9u128 . into( ) ) ,
381
+ max_object_pins: None ,
382
+ } ,
383
+ None ,
384
+ ) ,
385
+ (
386
+ BucketLimits {
387
+ max_objects: None ,
388
+ max_object_size: None ,
389
+ max_total_size: None ,
390
+ max_object_pins: Some ( 1u128 . into( ) ) ,
391
+ } ,
392
+ None ,
393
+ ) ,
394
+ (
395
+ BucketLimits {
396
+ max_objects: Some ( 1u128 . into( ) ) ,
397
+ max_object_size: None ,
398
+ max_total_size: None ,
399
+ max_object_pins: None ,
400
+ } ,
401
+ Some ( MaxObjectsLimitExceeded { } ) ,
402
+ ) ,
403
+ (
404
+ BucketLimits {
405
+ max_objects: None ,
406
+ max_object_size: Some ( 4u128 . into( ) ) ,
407
+ max_total_size: None ,
408
+ max_object_pins: None ,
409
+ } ,
410
+ Some ( ObjectMaxSizeLimitExceeded { } ) ,
411
+ ) ,
412
+ (
413
+ BucketLimits {
414
+ max_objects: None ,
415
+ max_object_size: None ,
416
+ max_total_size: Some ( 8u128 . into( ) ) ,
417
+ max_object_pins: None ,
418
+ } ,
419
+ Some ( BucketSizeLimitExceeded { } ) ,
420
+ ) ,
421
+ (
422
+ BucketLimits {
423
+ max_objects: None ,
424
+ max_object_size: None ,
425
+ max_total_size: None ,
426
+ max_object_pins: Some ( 0u128 . into( ) ) ,
427
+ } ,
428
+ Some ( MaxObjectPinsLimitExceeded { } ) ,
429
+ ) ,
366
430
] ;
367
-
431
+
368
432
let obj1 = general_purpose:: STANDARD . encode ( "okp4" ) ;
369
433
let obj2 = general_purpose:: STANDARD . encode ( "hello" ) ;
370
434
@@ -378,9 +442,15 @@ mod tests {
378
442
} ;
379
443
instantiate ( deps. as_mut ( ) , mock_env ( ) , info. clone ( ) , msg) . unwrap ( ) ;
380
444
381
- let msg = ExecuteMsg :: StoreObject { data : Binary :: from_base64 ( obj1. as_str ( ) ) . unwrap ( ) , pin : false } ;
445
+ let msg = ExecuteMsg :: StoreObject {
446
+ data : Binary :: from_base64 ( obj1. as_str ( ) ) . unwrap ( ) ,
447
+ pin : false ,
448
+ } ;
382
449
execute ( deps. as_mut ( ) , mock_env ( ) , info. clone ( ) , msg) . unwrap ( ) ;
383
- let msg = ExecuteMsg :: StoreObject { data : Binary :: from_base64 ( obj2. as_str ( ) ) . unwrap ( ) , pin : true } ;
450
+ let msg = ExecuteMsg :: StoreObject {
451
+ data : Binary :: from_base64 ( obj2. as_str ( ) ) . unwrap ( ) ,
452
+ pin : true ,
453
+ } ;
384
454
let res = execute ( deps. as_mut ( ) , mock_env ( ) , info. clone ( ) , msg) ;
385
455
386
456
assert_eq ! ( res. err( ) , case. 1 ) ;
0 commit comments