mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
Switch Treasury to on_initialize, Tips KeepAlive (#5352)
* Switch Treasury to `on_initialize` * Fix bench compile
This commit is contained in:
@@ -6,7 +6,7 @@ use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill,
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, OnFinalize, IdentityLookup, BadOrigin},
|
||||
traits::{BlakeTwo256, OnInitialize, IdentityLookup, BadOrigin},
|
||||
};
|
||||
|
||||
impl_outer_origin! {
|
||||
@@ -60,6 +60,8 @@ impl Contains<u64> for TenToFourteen {
|
||||
fn sorted_members() -> Vec<u64> {
|
||||
vec![10, 11, 12, 13, 14]
|
||||
}
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn add(_: &u64) { unimplemented!() }
|
||||
}
|
||||
parameter_types! {
|
||||
pub const ProposalBond: Permill = Permill::from_percent(5);
|
||||
@@ -287,7 +289,7 @@ fn accepted_spend_proposal_ignored_outside_spend_period() {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0));
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(1);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(1);
|
||||
assert_eq!(Balances::free_balance(3), 0);
|
||||
assert_eq!(Treasury::pot(), 100);
|
||||
});
|
||||
@@ -300,7 +302,7 @@ fn unused_pot_should_diminish() {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), 101);
|
||||
assert_eq!(Balances::total_issuance(), init_total_issuance + 100);
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Treasury::pot(), 50);
|
||||
assert_eq!(Balances::total_issuance(), init_total_issuance + 50);
|
||||
});
|
||||
@@ -314,7 +316,7 @@ fn rejected_spend_proposal_ignored_on_spend_period() {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0));
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Balances::free_balance(3), 0);
|
||||
assert_eq!(Treasury::pot(), 50);
|
||||
});
|
||||
@@ -365,7 +367,7 @@ fn accepted_spend_proposal_enacted_on_spend_period() {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0));
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Balances::free_balance(3), 100);
|
||||
assert_eq!(Treasury::pot(), 0);
|
||||
});
|
||||
@@ -380,11 +382,11 @@ fn pot_underflow_should_not_diminish() {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 150, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0));
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(2);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(2);
|
||||
assert_eq!(Treasury::pot(), 100); // Pot hasn't changed
|
||||
|
||||
let _ = Balances::deposit_into_existing(&Treasury::account_id(), 100).unwrap();
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(4);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(4);
|
||||
assert_eq!(Balances::free_balance(3), 150); // Fund has been spent
|
||||
assert_eq!(Treasury::pot(), 25); // Pot has finally changed
|
||||
});
|
||||
@@ -402,13 +404,13 @@ fn treasury_account_doesnt_get_deleted() {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), treasury_balance, 3));
|
||||
assert_ok!(Treasury::approve_proposal(Origin::ROOT, 0));
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(2);
|
||||
<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));
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(4);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(4);
|
||||
assert_eq!(Treasury::pot(), 0); // Pot is emptied
|
||||
assert_eq!(Balances::free_balance(Treasury::account_id()), 1); // but the account is still there
|
||||
});
|
||||
@@ -433,7 +435,7 @@ fn inexistent_account_works() {
|
||||
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));
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(2);
|
||||
<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
|
||||
|
||||
@@ -441,7 +443,7 @@ fn inexistent_account_works() {
|
||||
assert_eq!(Treasury::pot(), 99); // Pot now contains funds
|
||||
assert_eq!(Balances::free_balance(Treasury::account_id()), 100); // Account does exist
|
||||
|
||||
<Treasury as OnFinalize<u64>>::on_finalize(4);
|
||||
<Treasury as OnInitialize<u64>>::on_initialize(4);
|
||||
|
||||
assert_eq!(Treasury::pot(), 0); // Pot has changed
|
||||
assert_eq!(Balances::free_balance(3), 99); // Balance of `3` has changed
|
||||
|
||||
Reference in New Issue
Block a user