Fix reset curator deposit when curator unassigns themself. (#10443)

This commit is contained in:
Gautam Dhameja
2021-12-09 15:16:35 +01:00
committed by GitHub
parent 3dd8f83a3a
commit 6ce90f583c
2 changed files with 40 additions and 0 deletions
+1
View File
@@ -453,6 +453,7 @@ pub mod pallet {
let err_amount = let err_amount =
T::Currency::unreserve(&curator, bounty.curator_deposit); T::Currency::unreserve(&curator, bounty.curator_deposit);
debug_assert!(err_amount.is_zero()); debug_assert!(err_amount.is_zero());
bounty.curator_deposit = Zero::zero();
// Continue to change bounty status below... // Continue to change bounty status below...
} }
}, },
+39
View File
@@ -1004,3 +1004,42 @@ fn genesis_funding_works() {
assert_eq!(Treasury::pot(), initial_funding - Balances::minimum_balance()); assert_eq!(Treasury::pot(), initial_funding - Balances::minimum_balance());
}); });
} }
#[test]
fn unassign_curator_self() {
new_test_ext().execute_with(|| {
System::set_block_number(1);
Balances::make_free_balance_be(&Treasury::account_id(), 101);
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 50, b"12345".to_vec()));
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
System::set_block_number(2);
<Treasury as OnInitialize<u64>>::on_initialize(2);
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 1, 10));
assert_ok!(Bounties::accept_curator(Origin::signed(1), 0));
assert_eq!(Balances::free_balance(1), 93);
assert_eq!(Balances::reserved_balance(1), 5);
System::set_block_number(8);
<Treasury as OnInitialize<u64>>::on_initialize(8);
assert_ok!(Bounties::unassign_curator(Origin::signed(1), 0));
assert_eq!(
Bounties::bounties(0).unwrap(),
Bounty {
proposer: 0,
fee: 10,
curator_deposit: 0,
value: 50,
bond: 85,
status: BountyStatus::Funded,
}
);
assert_eq!(Balances::free_balance(1), 98);
assert_eq!(Balances::reserved_balance(1), 0); // not slashed
});
}