Add benchmark tests for pallet bags list (#10593)

* Add benchmark tests for pallet bags list

* Make sure to set active balance for new ledgers

* fmt

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

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Zeke Mostov
2022-01-06 01:41:18 -08:00
committed by GitHub
parent cabfd35649
commit 0ca23e0a6c
3 changed files with 18 additions and 13 deletions
+4 -5
View File
@@ -1245,13 +1245,12 @@ impl<T: Config> VoteWeightProvider<T::AccountId> for Pallet<T> {
// this will clearly results in an inconsistent state, but it should not matter for a
// benchmark.
let active: BalanceOf<T> = weight.try_into().map_err(|_| ()).unwrap();
let ledger = match Self::ledger(who) {
let mut ledger = match Self::ledger(who) {
None => StakingLedger::default_from(who.clone()),
Some(mut l) => {
l.active = active;
l
},
Some(l) => l,
};
ledger.active = active;
<Ledger<T>>::insert(who, ledger);
<Bonded<T>>::insert(who, who);