Files
pezkuwi-sdk/pezcumulus/teyrchains/pezpallets/trust/src/benchmarking.rs
T
pezkuwichain 65b7f5e640 fix: Resolve cargo clippy errors and add CI workflow plan
## Changes

### Clippy Fixes
- Fixed deprecated `cargo_bin` usage in 27 test files (added #![allow(deprecated)])
- Fixed uninlined_format_args in zombienet-sdk-tests
- Fixed subxt API changes in revive/rpc/tests.rs (fetch signature, StorageValue)
- Fixed dead_code warnings in validator-pool and identity-kyc mocks
- Fixed field name `i` -> `_i` in tasks example

### CI Infrastructure
- Added .claude/WORKFLOW_PLAN.md for tracking CI fix progress
- Updated lychee.toml and taplo.toml configs

### Files Modified
- 27 test files with deprecated cargo_bin fix
- bizinikiwi/pezframe/revive/rpc/src/tests.rs (subxt API)
- pezkuwi/pezpallets/validator-pool/src/{mock,tests}.rs
- pezcumulus/teyrchains/pezpallets/identity-kyc/src/mock.rs
- bizinikiwi/pezframe/examples/tasks/src/tests.rs

## Status
- cargo clippy: PASSING
- Next: cargo fmt, zepter, workspace checks
2025-12-23 09:37:11 +03:00

69 lines
2.1 KiB
Rust

//! Benchmarking setup for pezpallet-trust
//!
//! These benchmarks measure the performance of trust score operations.
use super::*;
use pezframe_benchmarking::{v2::*, whitelisted_caller};
use pezframe_system::RawOrigin;
use pezsp_runtime::traits::Zero;
// We don't use IdentityKycPallet directly - just mock the citizenship status
// This simplifies benchmarks and avoids coupling with identity-kyc internals
#[benchmarks]
mod benchmarks {
use super::*;
/// Helper to setup a citizen for benchmarking
/// Instead of calling identity-kyc extrinsics, we mock the citizenship source
fn setup_citizen<T: Config>(account: &T::AccountId) {
// For benchmarks, we rely on the runtime's CitizenshipSource implementation
// The benchmark mock should configure CitizenshipSource to return true for whitelisted
// accounts This is typically done via TestCitizenshipProvider in mock.rs
// Initialize trust score storage for the account so update operations work
TrustScores::<T>::insert(account, T::Score::zero());
}
#[benchmark]
fn force_recalculate_trust_score() -> Result<(), BenchmarkError> {
// Setup
let account: T::AccountId = whitelisted_caller();
setup_citizen::<T>(&account);
#[extrinsic_call]
force_recalculate_trust_score(RawOrigin::Root, account.clone());
// Verify - trust score should be calculated (may be zero if no component scores)
assert!(TrustScores::<T>::contains_key(&account));
Ok(())
}
#[benchmark]
fn update_all_trust_scores() {
// Setup - Ensure no batch update is in progress
crate::BatchUpdateInProgress::<T>::put(false);
#[extrinsic_call]
update_all_trust_scores(RawOrigin::Root);
// Verify - The function completed (may or may not have set BatchUpdateInProgress
// depending on whether there are citizens to process)
// We just verify it doesn't panic
}
#[benchmark]
fn periodic_trust_score_update() {
// Setup - Ensure no batch update is in progress
crate::BatchUpdateInProgress::<T>::put(false);
#[extrinsic_call]
periodic_trust_score_update(RawOrigin::Root);
// Verify - The function completed successfully
}
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Test);
}