Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix reset curator deposit when curator unassigns themself. (#10443)
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamdhameja authored Dec 9, 2021
1 parent 8a3434b commit 6a634fb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions frame/bounties/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ pub mod pallet {
let err_amount =
T::Currency::unreserve(&curator, bounty.curator_deposit);
debug_assert!(err_amount.is_zero());
bounty.curator_deposit = Zero::zero();
// Continue to change bounty status below...
}
},
Expand Down
39 changes: 39 additions & 0 deletions frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,3 +1004,42 @@ fn genesis_funding_works() {
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
});
}

0 comments on commit 6a634fb

Please sign in to comment.