Add BoundedVec to Treasury Pallet (#8665)

* bounded treasury approvals

* update benchmarks

* update configs

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* fix weight param

Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
This commit is contained in:
Shawn Tabrizi
2021-04-26 10:42:09 -04:00
committed by GitHub
parent 052be8bbef
commit 4225d50881
7 changed files with 66 additions and 27 deletions
+19
View File
@@ -102,6 +102,7 @@ parameter_types! {
pub const BountyUpdatePeriod: u32 = 20;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: u64 = 1;
pub const MaxApprovals: u32 = 100;
}
impl Config for Test {
type PalletId = TreasuryPalletId;
@@ -117,6 +118,7 @@ impl Config for Test {
type BurnDestination = (); // Just gets burned.
type WeightInfo = ();
type SpendFunds = ();
type MaxApprovals = MaxApprovals;
}
pub fn new_test_ext() -> sp_io::TestExternalities {
@@ -359,3 +361,20 @@ fn genesis_funding_works() {
assert_eq!(Treasury::pot(), initial_funding - Balances::minimum_balance());
});
}
#[test]
fn max_approvals_limited() {
new_test_ext().execute_with(|| {
Balances::make_free_balance_be(&Treasury::account_id(), u64::max_value());
Balances::make_free_balance_be(&0, u64::max_value());
for _ in 0 .. MaxApprovals::get() {
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
assert_ok!(Treasury::approve_proposal(Origin::root(), 0));
}
// One too many will fail
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
assert_noop!(Treasury::approve_proposal(Origin::root(), 0), Error::<Test, _>::TooManyApprovals);
});
}