@@ -3096,49 +3096,60 @@ fn unbond_zero() {
30963096 } ) ;
30973097}
30983098
3099+ // Origin test case name is `yakio_q1`
30993100// bond 10_000 Ring for 12 months, gain 1 Kton
31003101// bond extra 10_000 Ring for 36 months, gain 3 Kton
31013102// bond extra 1 Kton
31023103// nominate
31033104// unlock the 12 months deposit item with punish
31043105// lost 3 Kton and 10_000 Ring's power for nominate
31053106#[ test]
3106- fn yakio_q1 ( ) {
3107+ fn two_different_bond_then_unbond_specific_one ( ) {
31073108 ExtBuilder :: default ( ) . build ( ) . execute_with ( || {
31083109 let ( stash, controller) = ( 777 , 888 ) ;
31093110 let _ = Ring :: deposit_creating ( & stash, 20_000 ) ;
31103111
3112+ // Earn 1 Kton with bond 10_000 Ring 12 months
31113113 assert_ok ! ( Staking :: bond(
31123114 Origin :: signed( stash) ,
31133115 controller,
31143116 StakingBalances :: RingBalance ( 10_000 ) ,
31153117 RewardDestination :: Stash ,
31163118 12 ,
31173119 ) ) ;
3120+
3121+ // Earn 3 Kton with bond 10_000 Ring 36 months
31183122 assert_ok ! ( Staking :: bond_extra(
31193123 Origin :: signed( stash) ,
31203124 StakingBalances :: RingBalance ( 10_000 ) ,
31213125 36 ,
31223126 ) ) ;
31233127 assert_eq ! ( Kton :: free_balance( & stash) , 4 ) ;
31243128
3129+ // Bond 1 Kton
31253130 assert_ok ! ( Staking :: bond_extra(
31263131 Origin :: signed( stash) ,
31273132 StakingBalances :: KtonBalance ( 1 ) ,
31283133 36
31293134 ) ) ;
31303135 assert_eq ! ( Staking :: ledger( controller) . unwrap( ) . active_kton, 1 ) ;
31313136
3137+ // Become a nominator
31323138 assert_ok ! ( Staking :: nominate( Origin :: signed( controller) , vec![ controller] ) ) ;
31333139
3140+ // Then unbond the the first 12 months part,
3141+ // this behavior should be punished 3 times Kton according to the remaining times
3142+ // 3 times * 1 Kton * 12 months(remaining) / 12 months(promised)
31343143 assert_ok ! ( Staking :: try_claim_deposits_with_punish(
31353144 Origin :: signed( controller) ,
31363145 12 * MONTH_IN_MILLISECONDS ,
31373146 ) ) ;
31383147 assert_eq ! ( Kton :: free_balance( & stash) , 1 ) ;
31393148
31403149 let ledger = Staking :: ledger ( controller) . unwrap ( ) ;
3141- // not enough Kton to unbond
3150+
3151+ // Please Note:
3152+ // not enough Kton to unbond, but the function will not fail
31423153 assert_ok ! ( Staking :: try_claim_deposits_with_punish(
31433154 Origin :: signed( controller) ,
31443155 36 * MONTH_IN_MILLISECONDS ,
@@ -3147,9 +3158,11 @@ fn yakio_q1() {
31473158 } ) ;
31483159}
31493160
3161+ // Origin test case name is `yakio_q2`
31503162// how to balance the power and calculate the reward if some validators have been chilled
3163+ // more reward with more validators
31513164#[ test]
3152- fn yakio_q2 ( ) {
3165+ fn nominator_voting_a_validator_before_he_chill ( ) {
31533166 fn run ( with_new_era : bool ) -> Balance {
31543167 let mut balance = 0 ;
31553168 ExtBuilder :: default ( ) . build ( ) . execute_with ( || {
@@ -3177,6 +3190,8 @@ fn yakio_q2() {
31773190 ) ) ;
31783191
31793192 start_era ( 1 ) ;
3193+
3194+ // A validator becomes to be chilled after the nominator voting him
31803195 assert_ok ! ( Staking :: chill( Origin :: signed( validator_1_controller) ) ) ;
31813196 // assert_ok!(Staking::chill(Origin::signed(validator_2_controller)));
31823197 if with_new_era {
@@ -3199,8 +3214,9 @@ fn yakio_q2() {
31993214 assert ! ( free_balance > free_balance_with_new_era) ;
32003215}
32013216
3217+ // Original testcase name is `xavier_q1`
32023218#[ test]
3203- fn xavier_q1 ( ) {
3219+ fn staking_with_kton_with_unbondings ( ) {
32043220 ExtBuilder :: default ( ) . build ( ) . execute_with ( || {
32053221 let stash = 123 ;
32063222 let controller = 456 ;
@@ -3524,8 +3540,11 @@ fn xavier_q1() {
35243540 } ) ;
35253541}
35263542
3543+ // Original testcase name is `xavier_q2`
3544+ //
3545+ // The values(KTON, RING) are unbond twice with different amount and times
35273546#[ test]
3528- fn xavier_q2 ( ) {
3547+ fn unbound_values_in_twice ( ) {
35293548 ExtBuilder :: default ( ) . build ( ) . execute_with ( || {
35303549 let stash = 123 ;
35313550 let controller = 456 ;
@@ -3955,8 +3974,11 @@ fn xavier_q2() {
39553974 } ) ;
39563975}
39573976
3977+ // Original testcase name is `xavier_q3`
3978+ //
3979+ // The values(KTON, RING) are unbond in the moment that there are values unbonding
39583980#[ test]
3959- fn bond_values_then_unbond_all_then_bond_again ( ) {
3981+ fn bond_values_when_some_value_unbonding ( ) {
39603982 // The Kton part
39613983 ExtBuilder :: default ( ) . build ( ) . execute_with ( || {
39623984 let stash = 123 ;
0 commit comments