diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 3dbe8cf7a..0d3e65f77 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -2532,30 +2532,7 @@ fn time_deposit_ring_unbond_and_withdraw_automatically_should_work() { reasons: WithdrawReasons::all(), }], ); - assert_eq!( - Staking::ledger(controller).unwrap(), - StakingLedger { - stash, - active_ring: 0, - active_deposit_ring: 0, - active_kton: 0, - deposit_items: vec![], - ring_staking_lock: StakingLock { - staking_amount: 0, - unbondings: vec![ - NormalLock { - amount: unbond_value, - until: BondingDuration::get(), - }, - NormalLock { - amount: 1000 - unbond_value, - until: unbond_start + BondingDuration::get(), - }, - ], - }, - kton_staking_lock: Default::default(), - }, - ); + assert_eq!(Staking::ledger(controller), None); assert_err!( Ring::transfer(Origin::signed(stash), controller, 1), @@ -3979,7 +3956,8 @@ fn xavier_q2() { } #[test] -fn xavier_q3() { +fn bond_values_then_unbond_all_then_bond_again() { + // The Kton part ExtBuilder::default().build().execute_with(|| { let stash = 123; let controller = 456; @@ -3993,6 +3971,7 @@ fn xavier_q3() { RewardDestination::Stash, 0, )); + assert_eq!(Timestamp::get(), 1); assert_eq!( Staking::ledger(controller).unwrap(), @@ -4009,38 +3988,22 @@ fn xavier_q3() { }, } ); - // println!("Locks: {:#?}", Kton::locks(stash)); - // println!("StakingLedger: {:#?}", Staking::ledger(controller)); - // println!(); + // all values are unbond assert_ok!(Staking::unbond( Origin::signed(controller), StakingBalances::KtonBalance(5) )); - assert_eq!( - Staking::ledger(controller).unwrap(), - StakingLedger { - stash: 123, - active_ring: 0, - active_deposit_ring: 0, - active_kton: 0, - deposit_items: vec![], - ring_staking_lock: Default::default(), - kton_staking_lock: StakingLock { - staking_amount: 0, - unbondings: vec![NormalLock { amount: 5, until: 61 }], - }, - } - ); - // println!("Locks: {:#?}", Kton::locks(stash)); - // println!("StakingLedger: {:#?}", Staking::ledger(controller)); - // println!(); + assert_eq!(Staking::ledger(controller), None); + // bond again Timestamp::set_timestamp(61); - assert_ok!(Staking::bond_extra( + assert_ok!(Staking::bond( Origin::signed(stash), + controller, StakingBalances::KtonBalance(1), - 0 + RewardDestination::Stash, + 0, )); assert_eq!(Timestamp::get(), 61); assert_eq!( @@ -4054,15 +4017,13 @@ fn xavier_q3() { ring_staking_lock: Default::default(), kton_staking_lock: StakingLock { staking_amount: 1, - unbondings: vec![NormalLock { amount: 5, until: 61 }], + unbondings: vec![], }, } ); - // println!("Locks: {:#?}", Kton::locks(stash)); - // println!("StakingLedger: {:#?}", Staking::ledger(controller)); - // println!(); }); + // The Ring part ExtBuilder::default().build().execute_with(|| { let stash = 123; let controller = 456; @@ -4092,38 +4053,22 @@ fn xavier_q3() { kton_staking_lock: Default::default(), } ); - // println!("Locks: {:#?}", Ring::locks(stash)); - // println!("StakingLedger: {:#?}", Staking::ledger(controller)); - // println!(); + // all values are unbond assert_ok!(Staking::unbond( Origin::signed(controller), StakingBalances::RingBalance(5), )); - assert_eq!( - Staking::ledger(controller).unwrap(), - StakingLedger { - stash: 123, - active_ring: 0, - active_deposit_ring: 0, - active_kton: 0, - deposit_items: vec![], - ring_staking_lock: StakingLock { - staking_amount: 0, - unbondings: vec![NormalLock { amount: 5, until: 61 }], - }, - kton_staking_lock: Default::default(), - } - ); - // println!("Locks: {:#?}", Ring::locks(stash)); - // println!("StakingLedger: {:#?}", Staking::ledger(controller)); - // println!(); + assert_eq!(Staking::ledger(controller), None); + // bond again Timestamp::set_timestamp(61); - assert_ok!(Staking::bond_extra( + assert_ok!(Staking::bond( Origin::signed(stash), + controller, StakingBalances::RingBalance(1), - 0 + RewardDestination::Stash, + 0, )); assert_eq!(Timestamp::get(), 61); assert_eq!( @@ -4136,14 +4081,11 @@ fn xavier_q3() { deposit_items: vec![], ring_staking_lock: StakingLock { staking_amount: 1, - unbondings: vec![NormalLock { amount: 5, until: 61 }], + unbondings: vec![], }, kton_staking_lock: Default::default(), } ); - // println!("Locks: {:#?}", Ring::locks(stash)); - // println!("StakingLedger: {:#?}", Staking::ledger(controller)); - // println!(); }); }