@@ -388,6 +388,58 @@ fn get_interest_after_withdraw() {
388
388
assert_eq ! ( 12_000_000 , interest. amount. total. 0 ) ;
389
389
}
390
390
391
+ #[ test]
392
+ #[ should_panic( expected = "Can be performed only by admin" ) ]
393
+ fn unlock_not_by_manager ( ) {
394
+ let alice = alice ( ) ;
395
+ let admin = admin ( ) ;
396
+
397
+ let reference_product = generate_product ( ) ;
398
+
399
+ let mut reference_jar = Jar :: generate ( 0 , & alice, & reference_product. id ) . principal ( 100 ) ;
400
+ reference_jar. is_pending_withdraw = true ;
401
+ let jars = & [ reference_jar] ;
402
+
403
+ let mut context = Context :: new ( admin) . with_products ( & [ reference_product] ) . with_jars ( jars) ;
404
+
405
+ context. switch_account ( & alice) ;
406
+ context. contract ( ) . unlock_jars_for_account ( alice) ;
407
+ }
408
+
409
+ #[ test]
410
+ fn unlock_by_manager ( ) {
411
+ let alice = alice ( ) ;
412
+ let admin = admin ( ) ;
413
+
414
+ let reference_product = generate_product ( ) ;
415
+
416
+ let reference_jar_id = 0 ;
417
+ let mut reference_jar = Jar :: generate ( reference_jar_id, & alice, & reference_product. id ) . principal ( 100 ) ;
418
+ reference_jar. is_pending_withdraw = true ;
419
+ let jars = & [ reference_jar] ;
420
+
421
+ let mut context = Context :: new ( admin. clone ( ) )
422
+ . with_products ( & [ reference_product] )
423
+ . with_jars ( jars) ;
424
+
425
+ assert ! (
426
+ context
427
+ . contract( )
428
+ . get_jar( alice. clone( ) , reference_jar_id. into( ) )
429
+ . is_pending_withdraw
430
+ ) ;
431
+
432
+ context. switch_account ( & admin) ;
433
+ context. contract ( ) . unlock_jars_for_account ( alice. clone ( ) ) ;
434
+
435
+ assert ! (
436
+ !context
437
+ . contract( )
438
+ . get_jar( alice. clone( ) , reference_jar_id. into( ) )
439
+ . is_pending_withdraw
440
+ ) ;
441
+ }
442
+
391
443
#[ test]
392
444
fn test_u32 ( ) {
393
445
let n = U32 ( 12345678 ) ;
0 commit comments