mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
BREAKING: Rename Origin (#12258)
* BREAKING: Rename Origin * more renaming * a bit more renaming * fix * more fixing * fix in frame_support * even more fixes * fix * small fix * ... * update .stderr * docs * update docs * update docs * docs
This commit is contained in:
@@ -98,7 +98,7 @@ benchmarks_instance_pallet! {
|
||||
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
||||
let bounty_id = BountyCount::<T, I>::get() - 1;
|
||||
let approve_origin = T::ApproveOrigin::successful_origin();
|
||||
}: _<T::Origin>(approve_origin, bounty_id)
|
||||
}: _<T::RuntimeOrigin>(approve_origin, bounty_id)
|
||||
|
||||
propose_curator {
|
||||
setup_pot_account::<T, I>();
|
||||
@@ -110,7 +110,7 @@ benchmarks_instance_pallet! {
|
||||
Bounties::<T, I>::approve_bounty(approve_origin, bounty_id)?;
|
||||
Treasury::<T, I>::on_initialize(T::BlockNumber::zero());
|
||||
let approve_origin = T::ApproveOrigin::successful_origin();
|
||||
}: _<T::Origin>(approve_origin, bounty_id, curator_lookup, fee)
|
||||
}: _<T::RuntimeOrigin>(approve_origin, bounty_id, curator_lookup, fee)
|
||||
|
||||
// Worst case when curator is inactive and any sender unassigns the curator.
|
||||
unassign_curator {
|
||||
@@ -171,7 +171,7 @@ benchmarks_instance_pallet! {
|
||||
Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?;
|
||||
let bounty_id = BountyCount::<T, I>::get() - 1;
|
||||
let approve_origin = T::ApproveOrigin::successful_origin();
|
||||
}: close_bounty<T::Origin>(approve_origin, bounty_id)
|
||||
}: close_bounty<T::RuntimeOrigin>(approve_origin, bounty_id)
|
||||
|
||||
close_bounty_active {
|
||||
setup_pot_account::<T, I>();
|
||||
@@ -179,7 +179,7 @@ benchmarks_instance_pallet! {
|
||||
Treasury::<T, I>::on_initialize(T::BlockNumber::zero());
|
||||
let bounty_id = BountyCount::<T, I>::get() - 1;
|
||||
let approve_origin = T::ApproveOrigin::successful_origin();
|
||||
}: close_bounty<T::Origin>(approve_origin, bounty_id)
|
||||
}: close_bounty<T::RuntimeOrigin>(approve_origin, bounty_id)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::BountyCanceled { index: bounty_id }.into())
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ impl frame_system::Config for Test {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
@@ -229,7 +229,7 @@ fn minting_works() {
|
||||
#[test]
|
||||
fn spend_proposal_takes_min_deposit() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 1, 3));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 1, 3));
|
||||
assert_eq!(Balances::free_balance(0), 99);
|
||||
assert_eq!(Balances::reserved_balance(0), 1);
|
||||
});
|
||||
@@ -238,7 +238,7 @@ fn spend_proposal_takes_min_deposit() {
|
||||
#[test]
|
||||
fn spend_proposal_takes_proportional_deposit() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 100, 3));
|
||||
assert_eq!(Balances::free_balance(0), 95);
|
||||
assert_eq!(Balances::reserved_balance(0), 5);
|
||||
});
|
||||
@@ -248,7 +248,7 @@ fn spend_proposal_takes_proportional_deposit() {
|
||||
fn spend_proposal_fails_when_proposer_poor() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
Treasury::propose_spend(Origin::signed(2), 100, 3),
|
||||
Treasury::propose_spend(RuntimeOrigin::signed(2), 100, 3),
|
||||
TreasuryError::InsufficientProposersBalance,
|
||||
);
|
||||
});
|
||||
@@ -259,8 +259,8 @@ fn accepted_spend_proposal_ignored_outside_spend_period() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::root(), 0));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(RuntimeOrigin::root(), 0));
|
||||
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(1);
|
||||
assert_eq!(Balances::free_balance(3), 0);
|
||||
@@ -286,8 +286,8 @@ fn rejected_spend_proposal_ignored_on_spend_period() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::root(), 0));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(RuntimeOrigin::root(), 0));
|
||||
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Balances::free_balance(3), 0);
|
||||
@@ -300,9 +300,12 @@ fn reject_already_rejected_spend_proposal_fails() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::root(), 0));
|
||||
assert_noop!(Treasury::reject_proposal(Origin::root(), 0), TreasuryError::InvalidIndex);
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(RuntimeOrigin::root(), 0));
|
||||
assert_noop!(
|
||||
Treasury::reject_proposal(RuntimeOrigin::root(), 0),
|
||||
TreasuryError::InvalidIndex
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -310,7 +313,7 @@ fn reject_already_rejected_spend_proposal_fails() {
|
||||
fn reject_non_existent_spend_proposal_fails() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(
|
||||
Treasury::reject_proposal(Origin::root(), 0),
|
||||
Treasury::reject_proposal(RuntimeOrigin::root(), 0),
|
||||
pallet_treasury::Error::<Test>::InvalidIndex
|
||||
);
|
||||
});
|
||||
@@ -319,7 +322,10 @@ fn reject_non_existent_spend_proposal_fails() {
|
||||
#[test]
|
||||
fn accept_non_existent_spend_proposal_fails() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_noop!(Treasury::approve_proposal(Origin::root(), 0), TreasuryError::InvalidIndex);
|
||||
assert_noop!(
|
||||
Treasury::approve_proposal(RuntimeOrigin::root(), 0),
|
||||
TreasuryError::InvalidIndex
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -328,9 +334,12 @@ fn accept_already_rejected_spend_proposal_fails() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::root(), 0));
|
||||
assert_noop!(Treasury::approve_proposal(Origin::root(), 0), TreasuryError::InvalidIndex);
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(RuntimeOrigin::root(), 0));
|
||||
assert_noop!(
|
||||
Treasury::approve_proposal(RuntimeOrigin::root(), 0),
|
||||
TreasuryError::InvalidIndex
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -340,8 +349,8 @@ fn accepted_spend_proposal_enacted_on_spend_period() {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::root(), 0));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(RuntimeOrigin::root(), 0));
|
||||
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Balances::free_balance(3), 100);
|
||||
@@ -355,8 +364,8 @@ fn pot_underflow_should_not_diminish() {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 150, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::root(), 0));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 150, 3));
|
||||
assert_ok!(Treasury::approve_proposal(RuntimeOrigin::root(), 0));
|
||||
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Treasury::pot(), 100); // Pot hasn't changed
|
||||
@@ -377,14 +386,14 @@ fn treasury_account_doesnt_get_deleted() {
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
let treasury_balance = Balances::free_balance(&Treasury::account_id());
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), treasury_balance, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::root(), 0));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), treasury_balance, 3));
|
||||
assert_ok!(Treasury::approve_proposal(RuntimeOrigin::root(), 0));
|
||||
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Treasury::pot(), 100); // Pot hasn't changed
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), Treasury::pot(), 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::root(), 1));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), Treasury::pot(), 3));
|
||||
assert_ok!(Treasury::approve_proposal(RuntimeOrigin::root(), 1));
|
||||
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(4);
|
||||
assert_eq!(Treasury::pot(), 0); // Pot is emptied
|
||||
@@ -407,10 +416,10 @@ fn inexistent_account_works() {
|
||||
assert_eq!(Balances::free_balance(Treasury::account_id()), 0); // Account does not exist
|
||||
assert_eq!(Treasury::pot(), 0); // Pot is empty
|
||||
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 99, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::root(), 0));
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 1, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::root(), 1));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 99, 3));
|
||||
assert_ok!(Treasury::approve_proposal(RuntimeOrigin::root(), 0));
|
||||
assert_ok!(Treasury::propose_spend(RuntimeOrigin::signed(0), 1, 3));
|
||||
assert_ok!(Treasury::approve_proposal(RuntimeOrigin::root(), 1));
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Treasury::pot(), 0); // Pot hasn't changed
|
||||
assert_eq!(Balances::free_balance(3), 0); // Balance of `3` hasn't changed
|
||||
@@ -434,7 +443,7 @@ fn propose_bounty_works() {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 10, b"1234567890".to_vec()));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 10, b"1234567890".to_vec()));
|
||||
|
||||
assert_eq!(last_event(), BountiesEvent::BountyProposed { index: 0 });
|
||||
|
||||
@@ -469,17 +478,21 @@ fn propose_bounty_validation_works() {
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
|
||||
assert_noop!(
|
||||
Bounties::propose_bounty(Origin::signed(1), 0, [0; 17_000].to_vec()),
|
||||
Bounties::propose_bounty(RuntimeOrigin::signed(1), 0, [0; 17_000].to_vec()),
|
||||
Error::<Test>::ReasonTooBig
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Bounties::propose_bounty(Origin::signed(1), 10, b"12345678901234567890".to_vec()),
|
||||
Bounties::propose_bounty(
|
||||
RuntimeOrigin::signed(1),
|
||||
10,
|
||||
b"12345678901234567890".to_vec()
|
||||
),
|
||||
Error::<Test>::InsufficientProposersBalance
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Bounties::propose_bounty(Origin::signed(1), 0, b"12345678901234567890".to_vec()),
|
||||
Bounties::propose_bounty(RuntimeOrigin::signed(1), 0, b"12345678901234567890".to_vec()),
|
||||
Error::<Test>::InvalidValue
|
||||
);
|
||||
});
|
||||
@@ -490,11 +503,11 @@ fn close_bounty_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(1);
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_noop!(Bounties::close_bounty(Origin::root(), 0), Error::<Test>::InvalidIndex);
|
||||
assert_noop!(Bounties::close_bounty(RuntimeOrigin::root(), 0), Error::<Test>::InvalidIndex);
|
||||
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 10, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 10, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::close_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::close_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
let deposit: u64 = 80 + 5;
|
||||
|
||||
@@ -515,11 +528,14 @@ fn approve_bounty_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::set_block_number(1);
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_noop!(Bounties::approve_bounty(Origin::root(), 0), Error::<Test>::InvalidIndex);
|
||||
assert_noop!(
|
||||
Bounties::approve_bounty(RuntimeOrigin::root(), 0),
|
||||
Error::<Test>::InvalidIndex
|
||||
);
|
||||
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
let deposit: u64 = 80 + 5;
|
||||
|
||||
@@ -536,7 +552,10 @@ fn approve_bounty_works() {
|
||||
);
|
||||
assert_eq!(Bounties::bounty_approvals(), vec![0]);
|
||||
|
||||
assert_noop!(Bounties::close_bounty(Origin::root(), 0), Error::<Test>::UnexpectedStatus);
|
||||
assert_noop!(
|
||||
Bounties::close_bounty(RuntimeOrigin::root(), 0),
|
||||
Error::<Test>::UnexpectedStatus
|
||||
);
|
||||
|
||||
// deposit not returned yet
|
||||
assert_eq!(Balances::reserved_balance(0), deposit);
|
||||
@@ -572,24 +591,24 @@ fn assign_curator_works() {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
|
||||
assert_noop!(
|
||||
Bounties::propose_curator(Origin::root(), 0, 4, 4),
|
||||
Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, 4),
|
||||
Error::<Test>::InvalidIndex
|
||||
);
|
||||
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
assert_noop!(
|
||||
Bounties::propose_curator(Origin::root(), 0, 4, 50),
|
||||
Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, 50),
|
||||
Error::<Test>::InvalidFee
|
||||
);
|
||||
|
||||
let fee = 4;
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 4, fee));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, fee));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -603,15 +622,18 @@ fn assign_curator_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_noop!(Bounties::accept_curator(Origin::signed(1), 0), Error::<Test>::RequireCurator);
|
||||
assert_noop!(
|
||||
Bounties::accept_curator(Origin::signed(4), 0),
|
||||
Bounties::accept_curator(RuntimeOrigin::signed(1), 0),
|
||||
Error::<Test>::RequireCurator
|
||||
);
|
||||
assert_noop!(
|
||||
Bounties::accept_curator(RuntimeOrigin::signed(4), 0),
|
||||
pallet_balances::Error::<Test, _>::InsufficientBalance
|
||||
);
|
||||
|
||||
Balances::make_free_balance_be(&4, 10);
|
||||
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(4), 0));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(4), 0));
|
||||
|
||||
let expected_deposit = Bounties::calculate_curator_deposit(&fee);
|
||||
|
||||
@@ -637,18 +659,18 @@ fn unassign_curator_works() {
|
||||
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::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
let fee = 4;
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 4, fee));
|
||||
assert_noop!(Bounties::unassign_curator(Origin::signed(1), 0), BadOrigin);
|
||||
assert_ok!(Bounties::unassign_curator(Origin::signed(4), 0));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, fee));
|
||||
assert_noop!(Bounties::unassign_curator(RuntimeOrigin::signed(1), 0), BadOrigin);
|
||||
assert_ok!(Bounties::unassign_curator(RuntimeOrigin::signed(4), 0));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -662,11 +684,11 @@ fn unassign_curator_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 4, fee));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, fee));
|
||||
Balances::make_free_balance_be(&4, 10);
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(4), 0));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(4), 0));
|
||||
let expected_deposit = Bounties::calculate_curator_deposit(&fee);
|
||||
assert_ok!(Bounties::unassign_curator(Origin::root(), 0));
|
||||
assert_ok!(Bounties::unassign_curator(RuntimeOrigin::root(), 0));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -691,26 +713,26 @@ fn award_and_claim_bounty_works() {
|
||||
System::set_block_number(1);
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
Balances::make_free_balance_be(&4, 10);
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
let fee = 4;
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 4, fee));
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(4), 0));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, fee));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(4), 0));
|
||||
|
||||
let expected_deposit = Bounties::calculate_curator_deposit(&fee);
|
||||
assert_eq!(Balances::free_balance(4), 10 - expected_deposit);
|
||||
|
||||
assert_noop!(
|
||||
Bounties::award_bounty(Origin::signed(1), 0, 3),
|
||||
Bounties::award_bounty(RuntimeOrigin::signed(1), 0, 3),
|
||||
Error::<Test>::RequireCurator
|
||||
);
|
||||
|
||||
assert_ok!(Bounties::award_bounty(Origin::signed(4), 0, 3));
|
||||
assert_ok!(Bounties::award_bounty(RuntimeOrigin::signed(4), 0, 3));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -724,14 +746,18 @@ fn award_and_claim_bounty_works() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_noop!(Bounties::claim_bounty(Origin::signed(1), 0), Error::<Test>::Premature);
|
||||
assert_noop!(Bounties::claim_bounty(RuntimeOrigin::signed(1), 0), Error::<Test>::Premature);
|
||||
|
||||
System::set_block_number(5);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(5);
|
||||
|
||||
assert_ok!(Balances::transfer(Origin::signed(0), Bounties::bounty_account_id(0), 10));
|
||||
assert_ok!(Balances::transfer(
|
||||
RuntimeOrigin::signed(0),
|
||||
Bounties::bounty_account_id(0),
|
||||
10
|
||||
));
|
||||
|
||||
assert_ok!(Bounties::claim_bounty(Origin::signed(1), 0));
|
||||
assert_ok!(Bounties::claim_bounty(RuntimeOrigin::signed(1), 0));
|
||||
|
||||
assert_eq!(
|
||||
last_event(),
|
||||
@@ -754,17 +780,17 @@ fn claim_handles_high_fee() {
|
||||
System::set_block_number(1);
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
Balances::make_free_balance_be(&4, 30);
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 4, 49));
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(4), 0));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, 49));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(4), 0));
|
||||
|
||||
assert_ok!(Bounties::award_bounty(Origin::signed(4), 0, 3));
|
||||
assert_ok!(Bounties::award_bounty(RuntimeOrigin::signed(4), 0, 3));
|
||||
|
||||
System::set_block_number(5);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(5);
|
||||
@@ -773,7 +799,7 @@ fn claim_handles_high_fee() {
|
||||
let res = Balances::slash(&Bounties::bounty_account_id(0), 10);
|
||||
assert_eq!(res.0.peek(), 10);
|
||||
|
||||
assert_ok!(Bounties::claim_bounty(Origin::signed(1), 0));
|
||||
assert_ok!(Bounties::claim_bounty(RuntimeOrigin::signed(1), 0));
|
||||
|
||||
assert_eq!(
|
||||
last_event(),
|
||||
@@ -796,14 +822,18 @@ fn cancel_and_refund() {
|
||||
|
||||
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::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
assert_ok!(Balances::transfer(Origin::signed(0), Bounties::bounty_account_id(0), 10));
|
||||
assert_ok!(Balances::transfer(
|
||||
RuntimeOrigin::signed(0),
|
||||
Bounties::bounty_account_id(0),
|
||||
10
|
||||
));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -819,9 +849,9 @@ fn cancel_and_refund() {
|
||||
|
||||
assert_eq!(Balances::free_balance(Bounties::bounty_account_id(0)), 60);
|
||||
|
||||
assert_noop!(Bounties::close_bounty(Origin::signed(0), 0), BadOrigin);
|
||||
assert_noop!(Bounties::close_bounty(RuntimeOrigin::signed(0), 0), BadOrigin);
|
||||
|
||||
assert_ok!(Bounties::close_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::close_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
// `- 25 + 10`
|
||||
assert_eq!(Treasury::pot(), 85);
|
||||
@@ -833,27 +863,30 @@ fn award_and_cancel() {
|
||||
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::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 0, 10));
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(0), 0));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 0, 10));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(0), 0));
|
||||
|
||||
assert_eq!(Balances::free_balance(0), 95);
|
||||
assert_eq!(Balances::reserved_balance(0), 5);
|
||||
|
||||
assert_ok!(Bounties::award_bounty(Origin::signed(0), 0, 3));
|
||||
assert_ok!(Bounties::award_bounty(RuntimeOrigin::signed(0), 0, 3));
|
||||
|
||||
// Cannot close bounty directly when payout is happening...
|
||||
assert_noop!(Bounties::close_bounty(Origin::root(), 0), Error::<Test>::PendingPayout);
|
||||
assert_noop!(
|
||||
Bounties::close_bounty(RuntimeOrigin::root(), 0),
|
||||
Error::<Test>::PendingPayout
|
||||
);
|
||||
|
||||
// Instead unassign the curator to slash them and then close.
|
||||
assert_ok!(Bounties::unassign_curator(Origin::root(), 0));
|
||||
assert_ok!(Bounties::close_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::unassign_curator(RuntimeOrigin::root(), 0));
|
||||
assert_ok!(Bounties::close_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
assert_eq!(last_event(), BountiesEvent::BountyCanceled { index: 0 });
|
||||
|
||||
@@ -873,15 +906,15 @@ fn expire_and_unassign() {
|
||||
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::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::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_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 1, 10));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(1), 0));
|
||||
|
||||
assert_eq!(Balances::free_balance(1), 93);
|
||||
assert_eq!(Balances::reserved_balance(1), 5);
|
||||
@@ -889,12 +922,15 @@ fn expire_and_unassign() {
|
||||
System::set_block_number(22);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(22);
|
||||
|
||||
assert_noop!(Bounties::unassign_curator(Origin::signed(0), 0), Error::<Test>::Premature);
|
||||
assert_noop!(
|
||||
Bounties::unassign_curator(RuntimeOrigin::signed(0), 0),
|
||||
Error::<Test>::Premature
|
||||
);
|
||||
|
||||
System::set_block_number(23);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(23);
|
||||
|
||||
assert_ok!(Bounties::unassign_curator(Origin::signed(0), 0));
|
||||
assert_ok!(Bounties::unassign_curator(RuntimeOrigin::signed(0), 0));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -919,20 +955,20 @@ fn extend_expiry() {
|
||||
System::set_block_number(1);
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
Balances::make_free_balance_be(&4, 10);
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
|
||||
assert_noop!(
|
||||
Bounties::extend_bounty_expiry(Origin::signed(1), 0, Vec::new()),
|
||||
Bounties::extend_bounty_expiry(RuntimeOrigin::signed(1), 0, Vec::new()),
|
||||
Error::<Test>::UnexpectedStatus
|
||||
);
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), 0, 4, 10));
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(4), 0));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 4, 10));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(4), 0));
|
||||
|
||||
assert_eq!(Balances::free_balance(4), 5);
|
||||
assert_eq!(Balances::reserved_balance(4), 5);
|
||||
@@ -941,10 +977,10 @@ fn extend_expiry() {
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(10);
|
||||
|
||||
assert_noop!(
|
||||
Bounties::extend_bounty_expiry(Origin::signed(0), 0, Vec::new()),
|
||||
Bounties::extend_bounty_expiry(RuntimeOrigin::signed(0), 0, Vec::new()),
|
||||
Error::<Test>::RequireCurator
|
||||
);
|
||||
assert_ok!(Bounties::extend_bounty_expiry(Origin::signed(4), 0, Vec::new()));
|
||||
assert_ok!(Bounties::extend_bounty_expiry(RuntimeOrigin::signed(4), 0, Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -958,7 +994,7 @@ fn extend_expiry() {
|
||||
}
|
||||
);
|
||||
|
||||
assert_ok!(Bounties::extend_bounty_expiry(Origin::signed(4), 0, Vec::new()));
|
||||
assert_ok!(Bounties::extend_bounty_expiry(RuntimeOrigin::signed(4), 0, Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -975,8 +1011,11 @@ fn extend_expiry() {
|
||||
System::set_block_number(25);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(25);
|
||||
|
||||
assert_noop!(Bounties::unassign_curator(Origin::signed(0), 0), Error::<Test>::Premature);
|
||||
assert_ok!(Bounties::unassign_curator(Origin::signed(4), 0));
|
||||
assert_noop!(
|
||||
Bounties::unassign_curator(RuntimeOrigin::signed(0), 0),
|
||||
Error::<Test>::Premature
|
||||
);
|
||||
assert_ok!(Bounties::unassign_curator(RuntimeOrigin::signed(4), 0));
|
||||
|
||||
assert_eq!(Balances::free_balance(4), 10); // not slashed
|
||||
assert_eq!(Balances::reserved_balance(4), 0);
|
||||
@@ -1049,14 +1088,14 @@ 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));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::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_ok!(Bounties::propose_curator(RuntimeOrigin::root(), 0, 1, 10));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(1), 0));
|
||||
|
||||
assert_eq!(Balances::free_balance(1), 93);
|
||||
assert_eq!(Balances::reserved_balance(1), 5);
|
||||
@@ -1064,7 +1103,7 @@ fn unassign_curator_self() {
|
||||
System::set_block_number(8);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(8);
|
||||
|
||||
assert_ok!(Bounties::unassign_curator(Origin::signed(1), 0));
|
||||
assert_ok!(Bounties::unassign_curator(RuntimeOrigin::signed(1), 0));
|
||||
|
||||
assert_eq!(
|
||||
Bounties::bounties(0).unwrap(),
|
||||
@@ -1097,14 +1136,14 @@ fn accept_curator_handles_different_deposit_calculations() {
|
||||
System::set_block_number(1);
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
Balances::make_free_balance_be(&user, 100);
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), value, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), bounty_index));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), value, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), bounty_index));
|
||||
|
||||
System::set_block_number(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), bounty_index, user, fee));
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(user), bounty_index));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), bounty_index, user, fee));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(user), bounty_index));
|
||||
|
||||
let expected_deposit = CuratorDepositMultiplier::get() * fee;
|
||||
assert_eq!(Balances::free_balance(&user), 100 - expected_deposit);
|
||||
@@ -1119,14 +1158,14 @@ fn accept_curator_handles_different_deposit_calculations() {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
Balances::make_free_balance_be(&user, 100);
|
||||
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), value, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), bounty_index));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), value, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), bounty_index));
|
||||
|
||||
System::set_block_number(4);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(4);
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), bounty_index, user, fee));
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(user), bounty_index));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), bounty_index, user, fee));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(user), bounty_index));
|
||||
|
||||
let expected_deposit = CuratorDepositMin::get();
|
||||
assert_eq!(Balances::free_balance(&user), 100 - expected_deposit);
|
||||
@@ -1143,14 +1182,14 @@ fn accept_curator_handles_different_deposit_calculations() {
|
||||
Balances::make_free_balance_be(&user, starting_balance);
|
||||
Balances::make_free_balance_be(&0, starting_balance);
|
||||
|
||||
assert_ok!(Bounties::propose_bounty(Origin::signed(0), value, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::approve_bounty(Origin::root(), bounty_index));
|
||||
assert_ok!(Bounties::propose_bounty(RuntimeOrigin::signed(0), value, b"12345".to_vec()));
|
||||
assert_ok!(Bounties::approve_bounty(RuntimeOrigin::root(), bounty_index));
|
||||
|
||||
System::set_block_number(6);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(6);
|
||||
|
||||
assert_ok!(Bounties::propose_curator(Origin::root(), bounty_index, user, fee));
|
||||
assert_ok!(Bounties::accept_curator(Origin::signed(user), bounty_index));
|
||||
assert_ok!(Bounties::propose_curator(RuntimeOrigin::root(), bounty_index, user, fee));
|
||||
assert_ok!(Bounties::accept_curator(RuntimeOrigin::signed(user), bounty_index));
|
||||
|
||||
let expected_deposit = CuratorDepositMax::get();
|
||||
assert_eq!(Balances::free_balance(&user), starting_balance - expected_deposit);
|
||||
@@ -1170,8 +1209,8 @@ fn approve_bounty_works_second_instance() {
|
||||
assert_eq!(Balances::free_balance(&Treasury::account_id()), 101);
|
||||
assert_eq!(Balances::free_balance(&Treasury1::account_id()), 201);
|
||||
|
||||
assert_ok!(Bounties1::propose_bounty(Origin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties1::approve_bounty(Origin::root(), 0));
|
||||
assert_ok!(Bounties1::propose_bounty(RuntimeOrigin::signed(0), 50, b"12345".to_vec()));
|
||||
assert_ok!(Bounties1::approve_bounty(RuntimeOrigin::root(), 0));
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
<Treasury1 as OnInitialize<u64>>::on_initialize(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user