@@ -1285,6 +1285,59 @@ mod claim_payout {
12851285 } ) ;
12861286 }
12871287
1288+ #[ test]
1289+ fn pending_rewards_per_member_works ( ) {
1290+ ExtBuilder :: default ( ) . build_and_execute ( || {
1291+ let ed = Balances :: minimum_balance ( ) ;
1292+
1293+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 0 ) ) ;
1294+ Balances :: mutate_account ( & default_reward_account ( ) , |f| f. free += 30 ) . unwrap ( ) ;
1295+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 30 ) ) ;
1296+ assert_eq ! ( Pools :: pending_rewards( 20 ) , None ) ;
1297+
1298+ Balances :: make_free_balance_be ( & 20 , ed + 10 ) ;
1299+ assert_ok ! ( Pools :: join( Origin :: signed( 20 ) , 10 , 1 ) ) ;
1300+
1301+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 30 ) ) ;
1302+ assert_eq ! ( Pools :: pending_rewards( 20 ) , Some ( 0 ) ) ;
1303+
1304+ Balances :: mutate_account ( & default_reward_account ( ) , |f| f. free += 100 ) . unwrap ( ) ;
1305+
1306+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 30 + 50 ) ) ;
1307+ assert_eq ! ( Pools :: pending_rewards( 20 ) , Some ( 50 ) ) ;
1308+ assert_eq ! ( Pools :: pending_rewards( 30 ) , None ) ;
1309+
1310+ Balances :: make_free_balance_be ( & 30 , ed + 10 ) ;
1311+ assert_ok ! ( Pools :: join( Origin :: signed( 30 ) , 10 , 1 ) ) ;
1312+
1313+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 30 + 50 ) ) ;
1314+ assert_eq ! ( Pools :: pending_rewards( 20 ) , Some ( 50 ) ) ;
1315+ assert_eq ! ( Pools :: pending_rewards( 30 ) , Some ( 0 ) ) ;
1316+
1317+ Balances :: mutate_account ( & default_reward_account ( ) , |f| f. free += 60 ) . unwrap ( ) ;
1318+
1319+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 30 + 50 + 20 ) ) ;
1320+ assert_eq ! ( Pools :: pending_rewards( 20 ) , Some ( 50 + 20 ) ) ;
1321+ assert_eq ! ( Pools :: pending_rewards( 30 ) , Some ( 20 ) ) ;
1322+
1323+ // 10 should claim 10, 20 should claim nothing.
1324+ assert_ok ! ( Pools :: claim_payout( Origin :: signed( 10 ) ) ) ;
1325+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 0 ) ) ;
1326+ assert_eq ! ( Pools :: pending_rewards( 20 ) , Some ( 50 + 20 ) ) ;
1327+ assert_eq ! ( Pools :: pending_rewards( 30 ) , Some ( 20 ) ) ;
1328+
1329+ assert_ok ! ( Pools :: claim_payout( Origin :: signed( 20 ) ) ) ;
1330+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 0 ) ) ;
1331+ assert_eq ! ( Pools :: pending_rewards( 20 ) , Some ( 0 ) ) ;
1332+ assert_eq ! ( Pools :: pending_rewards( 30 ) , Some ( 20 ) ) ;
1333+
1334+ assert_ok ! ( Pools :: claim_payout( Origin :: signed( 30 ) ) ) ;
1335+ assert_eq ! ( Pools :: pending_rewards( 10 ) , Some ( 0 ) ) ;
1336+ assert_eq ! ( Pools :: pending_rewards( 20 ) , Some ( 0 ) ) ;
1337+ assert_eq ! ( Pools :: pending_rewards( 30 ) , Some ( 0 ) ) ;
1338+ } ) ;
1339+ }
1340+
12881341 #[ test]
12891342 fn rewards_distribution_is_fair_bond_extra ( ) {
12901343 ExtBuilder :: default ( ) . build_and_execute ( || {
0 commit comments