@@ -3373,78 +3373,6 @@ fn lock_correctly_considers_unlocking_amount() {
3373
3373
} )
3374
3374
}
3375
3375
3376
- #[ test]
3377
- fn fix_account_scenarios_work ( ) {
3378
- ExtBuilder :: default ( ) . build_and_execute ( || {
3379
- // 1. Lock some amount correctly, unstake it, try to fix it, and ensure the call fails
3380
- let ( account_1, lock_1) = ( 1 , 100 ) ;
3381
- assert_lock ( account_1, lock_1) ;
3382
- assert_noop ! (
3383
- DappStaking :: fix_account( RuntimeOrigin :: signed( 11 ) , account_1) ,
3384
- Error :: <Test >:: AccountNotInconsistent
3385
- ) ;
3386
-
3387
- assert_unlock ( account_1, lock_1) ;
3388
- assert_noop ! (
3389
- DappStaking :: fix_account( RuntimeOrigin :: signed( 11 ) , account_1) ,
3390
- Error :: <Test >:: AccountNotInconsistent
3391
- ) ;
3392
-
3393
- // 2. Reproduce the issue where the account has more frozen than balance
3394
- let ( account_2, unlock_2) = ( 2 , 13 ) ;
3395
- let lock_2 = Balances :: total_balance ( & account_2) ;
3396
- assert_lock ( account_2, lock_2) ;
3397
- assert_unlock ( account_2, unlock_2) ;
3398
-
3399
- // With the fix implemented, the scenario needs to be reproduced by hand.
3400
- // Account calls `lock`, specifying the amount that is undergoing the unlocking process.
3401
- // It can be either more or less, it doesn't matter for the test or the issue.
3402
-
3403
- // But first, a sanity check.
3404
- assert_noop ! (
3405
- DappStaking :: lock( RuntimeOrigin :: signed( account_2) , unlock_2) ,
3406
- Error :: <Test >:: ZeroAmount ,
3407
- ) ;
3408
-
3409
- // Now reproduce the incorrect lock/freeze operation.
3410
- let mut ledger = Ledger :: < Test > :: get ( & account_2) ;
3411
- ledger. add_lock_amount ( unlock_2) ;
3412
- assert_ok ! ( DappStaking :: update_ledger( & account_2, ledger) ) ;
3413
- use crate :: CurrentEraInfo ;
3414
- CurrentEraInfo :: < Test > :: mutate ( |era_info| {
3415
- era_info. add_locked ( unlock_2) ;
3416
- } ) ;
3417
- assert ! (
3418
- Balances :: free_balance( & account_2)
3419
- < Ledger :: <Test >:: get( & account_2) . total_locked_amount( ) ,
3420
- "Sanity check."
3421
- ) ;
3422
-
3423
- // Now fix the account
3424
- assert_ok ! ( DappStaking :: fix_account(
3425
- RuntimeOrigin :: signed( 11 ) ,
3426
- account_2
3427
- ) ) ;
3428
- System :: assert_last_event ( RuntimeEvent :: DappStaking ( Event :: ClaimedUnlocked {
3429
- account : account_2,
3430
- amount : unlock_2,
3431
- } ) ) ;
3432
-
3433
- // Post-fix checks
3434
- assert_eq ! (
3435
- Balances :: free_balance( & account_2) ,
3436
- Ledger :: <Test >:: get( & account_2) . total_locked_amount( ) ,
3437
- "After the fix, balances should be equal."
3438
- ) ;
3439
-
3440
- // Cannot fix the same account again.
3441
- assert_noop ! (
3442
- DappStaking :: fix_account( RuntimeOrigin :: signed( 11 ) , account_2) ,
3443
- Error :: <Test >:: AccountNotInconsistent
3444
- ) ;
3445
- } )
3446
- }
3447
-
3448
3376
#[ test]
3449
3377
fn claim_staker_rewards_for_basic_example_is_ok ( ) {
3450
3378
ExtBuilder :: default ( ) . build_and_execute ( || {
0 commit comments