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
This commit is contained in:
@@ -15,20 +15,20 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { workspace = true, default-features = false, features = [
|
||||
"derive",
|
||||
"max-encoded-len",
|
||||
"derive",
|
||||
"max-encoded-len",
|
||||
] }
|
||||
scale-info = { default-features = false, features = [
|
||||
"derive",
|
||||
"derive",
|
||||
], workspace = true }
|
||||
serde = { version = "1.0", default-features = false, features = [
|
||||
"derive",
|
||||
"derive",
|
||||
], optional = true }
|
||||
|
||||
log = { default-features = false, workspace = true }
|
||||
pezframe-benchmarking = { optional = true, workspace = true }
|
||||
pezframe-support = { default-features = false, workspace = true }
|
||||
pezframe-system = { default-features = false, workspace = true }
|
||||
log = { default-features = false, workspace = true }
|
||||
pezsp-core = { workspace = true, default-features = false, optional = true }
|
||||
pezsp-io = { workspace = true, default-features = false, optional = true }
|
||||
pezsp-runtime = { default-features = false, workspace = true }
|
||||
@@ -58,69 +58,69 @@ pezsp-io = { workspace = true, default-features = false }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezframe-benchmarking?/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"log/std",
|
||||
"pezpallet-balances/std",
|
||||
"pezpallet-collective/std",
|
||||
"pezpallet-democracy/std",
|
||||
"pezpallet-elections-phragmen/std",
|
||||
"pezpallet-identity-kyc/std",
|
||||
"pezpallet-identity/std",
|
||||
"pezpallet-nfts/std",
|
||||
"pezpallet-referral/std",
|
||||
"pezpallet-scheduler/std",
|
||||
"pezpallet-staking-score/std",
|
||||
"pezpallet-tiki/std",
|
||||
"pezpallet-timestamp/std",
|
||||
"pezpallet-trust/std",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
"serde?/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-io/std",
|
||||
"pezsp-runtime/std",
|
||||
"pezsp-std/std",
|
||||
"codec/std",
|
||||
"log/std",
|
||||
"pezframe-benchmarking?/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"pezpallet-balances/std",
|
||||
"pezpallet-collective/std",
|
||||
"pezpallet-democracy/std",
|
||||
"pezpallet-elections-phragmen/std",
|
||||
"pezpallet-identity-kyc/std",
|
||||
"pezpallet-identity/std",
|
||||
"pezpallet-nfts/std",
|
||||
"pezpallet-referral/std",
|
||||
"pezpallet-scheduler/std",
|
||||
"pezpallet-staking-score/std",
|
||||
"pezpallet-tiki/std",
|
||||
"pezpallet-timestamp/std",
|
||||
"pezpallet-trust/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-io/std",
|
||||
"pezsp-runtime/std",
|
||||
"pezsp-std/std",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
"serde?/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-benchmarking/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-collective/runtime-benchmarks",
|
||||
"pezpallet-democracy/runtime-benchmarks",
|
||||
"pezpallet-elections-phragmen/runtime-benchmarks",
|
||||
"pezpallet-identity-kyc/runtime-benchmarks",
|
||||
"pezpallet-identity/runtime-benchmarks",
|
||||
"pezpallet-nfts/runtime-benchmarks",
|
||||
"pezpallet-referral/runtime-benchmarks",
|
||||
"pezpallet-scheduler/runtime-benchmarks",
|
||||
"pezpallet-staking-score/runtime-benchmarks",
|
||||
"pezpallet-tiki/runtime-benchmarks",
|
||||
"pezpallet-timestamp/runtime-benchmarks",
|
||||
"pezpallet-trust/runtime-benchmarks",
|
||||
"pezsp-core",
|
||||
"pezsp-io",
|
||||
"pezsp-io?/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
"pezframe-benchmarking/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-collective/runtime-benchmarks",
|
||||
"pezpallet-democracy/runtime-benchmarks",
|
||||
"pezpallet-elections-phragmen/runtime-benchmarks",
|
||||
"pezpallet-identity-kyc/runtime-benchmarks",
|
||||
"pezpallet-identity/runtime-benchmarks",
|
||||
"pezpallet-nfts/runtime-benchmarks",
|
||||
"pezpallet-referral/runtime-benchmarks",
|
||||
"pezpallet-scheduler/runtime-benchmarks",
|
||||
"pezpallet-staking-score/runtime-benchmarks",
|
||||
"pezpallet-tiki/runtime-benchmarks",
|
||||
"pezpallet-timestamp/runtime-benchmarks",
|
||||
"pezpallet-trust/runtime-benchmarks",
|
||||
"pezsp-core",
|
||||
"pezsp-io",
|
||||
"pezsp-io?/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezpallet-balances/try-runtime",
|
||||
"pezpallet-collective/try-runtime",
|
||||
"pezpallet-democracy/try-runtime",
|
||||
"pezpallet-elections-phragmen/try-runtime",
|
||||
"pezpallet-identity-kyc/try-runtime",
|
||||
"pezpallet-identity/try-runtime",
|
||||
"pezpallet-nfts/try-runtime",
|
||||
"pezpallet-referral/try-runtime",
|
||||
"pezpallet-scheduler/try-runtime",
|
||||
"pezpallet-staking-score/try-runtime",
|
||||
"pezpallet-tiki/try-runtime",
|
||||
"pezpallet-timestamp/try-runtime",
|
||||
"pezpallet-trust/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezpallet-balances/try-runtime",
|
||||
"pezpallet-collective/try-runtime",
|
||||
"pezpallet-democracy/try-runtime",
|
||||
"pezpallet-elections-phragmen/try-runtime",
|
||||
"pezpallet-identity-kyc/try-runtime",
|
||||
"pezpallet-identity/try-runtime",
|
||||
"pezpallet-nfts/try-runtime",
|
||||
"pezpallet-referral/try-runtime",
|
||||
"pezpallet-scheduler/try-runtime",
|
||||
"pezpallet-staking-score/try-runtime",
|
||||
"pezpallet-tiki/try-runtime",
|
||||
"pezpallet-timestamp/try-runtime",
|
||||
"pezpallet-trust/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
use crate::types::*;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
@@ -165,7 +163,7 @@ mod benchmarks {
|
||||
|
||||
assert_eq!(NextAppointmentId::<T>::get(), 1);
|
||||
// Verify that the role is still not filled (nomination doesn't fill it, approval does)
|
||||
assert!(!AppointedOfficials::<T>::contains_key(&OfficialRole::Dadger));
|
||||
assert!(!AppointedOfficials::<T>::contains_key(OfficialRole::Dadger));
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
@@ -198,7 +196,7 @@ mod benchmarks {
|
||||
assert_eq!(NextAppointmentId::<T>::get(), 1);
|
||||
// CRITICAL: Verify that the role was assigned in AppointedOfficials storage
|
||||
// This tests the new storage write we added in lib.rs approve_appointment()
|
||||
assert_eq!(AppointedOfficials::<T>::get(&OfficialRole::Dozger), Some(nominee));
|
||||
assert_eq!(AppointedOfficials::<T>::get(OfficialRole::Dozger), Some(nominee));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
@@ -196,7 +196,9 @@ use pezframe_support::{
|
||||
weights::Weight,
|
||||
};
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezpallet_identity_kyc::types::{KycLevel, KycStatus};
|
||||
#[cfg(not(any(test, feature = "runtime-benchmarks")))]
|
||||
use pezpallet_identity_kyc::types::KycLevel;
|
||||
use pezpallet_identity_kyc::types::KycStatus;
|
||||
use pezpallet_tiki::{Tiki, TikiScoreProvider};
|
||||
use pezpallet_trust::TrustScoreProvider;
|
||||
use pezsp_runtime::traits::Dispatchable;
|
||||
@@ -218,14 +220,12 @@ pub mod pezpallet {
|
||||
|
||||
#[pezpallet::config]
|
||||
pub trait Config:
|
||||
pezframe_system::Config
|
||||
pezframe_system::Config<RuntimeEvent: From<Event<Self>>>
|
||||
+ pezpallet_tiki::Config
|
||||
+ pezpallet_trust::Config
|
||||
+ pezpallet_identity_kyc::Config
|
||||
+ core::fmt::Debug
|
||||
{
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type WeightInfo: crate::WeightInfo;
|
||||
type Randomness: Randomness<Self::Hash, BlockNumberFor<Self>>;
|
||||
type RuntimeCall: Parameter
|
||||
@@ -603,7 +603,7 @@ pub mod pezpallet {
|
||||
|
||||
let election_info = ElectionInfo {
|
||||
election_id,
|
||||
election_type: election_type.clone(),
|
||||
election_type,
|
||||
start_block: current_block,
|
||||
candidacy_deadline,
|
||||
campaign_start,
|
||||
@@ -897,11 +897,11 @@ pub mod pezpallet {
|
||||
ensure!(is_serok || is_minister, Error::<T>::NotAuthorizedToNominate);
|
||||
|
||||
// Check if role is already filled
|
||||
ensure!(!AppointedOfficials::<T>::contains_key(&role), Error::<T>::RoleAlreadyFilled);
|
||||
ensure!(!AppointedOfficials::<T>::contains_key(role), Error::<T>::RoleAlreadyFilled);
|
||||
|
||||
// Check if this specific nominee already has a pending nomination for this role
|
||||
ensure!(
|
||||
!PendingNominations::<T>::contains_key(&role, &nominee),
|
||||
!PendingNominations::<T>::contains_key(role, &nominee),
|
||||
Error::<T>::RoleAlreadyFilled
|
||||
);
|
||||
|
||||
@@ -924,17 +924,17 @@ pub mod pezpallet {
|
||||
};
|
||||
|
||||
// Store nomination
|
||||
PendingNominations::<T>::insert(&role, &nominee, nomination);
|
||||
PendingNominations::<T>::insert(role, &nominee, nomination);
|
||||
|
||||
// Create appointment process
|
||||
let documents: BoundedVec<BoundedVec<u8, ConstU32<1000>>, ConstU32<10>> =
|
||||
vec![justification.try_into().map_err(|_| Error::<T>::CalculationOverflow)?]
|
||||
vec![justification]
|
||||
.try_into()
|
||||
.map_err(|_| Error::<T>::CalculationOverflow)?;
|
||||
|
||||
let appointment_process = AppointmentProcess {
|
||||
process_id,
|
||||
position: role.clone(),
|
||||
position: role,
|
||||
nominating_minister: nominator.clone(),
|
||||
nominee: nominee.clone(),
|
||||
initiated_at: current_block,
|
||||
@@ -978,7 +978,7 @@ pub mod pezpallet {
|
||||
);
|
||||
|
||||
// Get nomination
|
||||
let mut nomination = PendingNominations::<T>::get(&process.position, &process.nominee)
|
||||
let mut nomination = PendingNominations::<T>::get(process.position, &process.nominee)
|
||||
.ok_or(Error::<T>::NominationNotFound)?;
|
||||
|
||||
// Update nomination
|
||||
@@ -992,11 +992,11 @@ pub mod pezpallet {
|
||||
process.status = AppointmentStatus::Approved;
|
||||
|
||||
// Store updates
|
||||
PendingNominations::<T>::insert(&process.position, &process.nominee, nomination);
|
||||
PendingNominations::<T>::insert(process.position, &process.nominee, nomination);
|
||||
AppointmentProcesses::<T>::insert(process_id, process.clone());
|
||||
|
||||
// Assign the official to the role
|
||||
AppointedOfficials::<T>::insert(&process.position, &process.nominee);
|
||||
AppointedOfficials::<T>::insert(process.position, &process.nominee);
|
||||
|
||||
Self::deposit_event(Event::AppointmentApproved {
|
||||
process_id,
|
||||
@@ -1259,7 +1259,7 @@ pub mod pezpallet {
|
||||
_ => {
|
||||
let trust_score = T::TrustScoreSource::trust_score_of(voter);
|
||||
let weight = (trust_score / 100) as u32;
|
||||
weight.max(1).min(10)
|
||||
weight.clamp(1, 10)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
pub mod v1 {
|
||||
use super::*;
|
||||
|
||||
/// Type alias for the pre-upgrade state tuple to reduce type complexity
|
||||
#[cfg(feature = "try-runtime")]
|
||||
type PreUpgradeState = (u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32);
|
||||
|
||||
pub struct MigrateToV1<T>(PhantomData<T>);
|
||||
|
||||
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
|
||||
@@ -22,13 +26,10 @@ pub mod v1 {
|
||||
let current = Pezpallet::<T>::on_chain_storage_version();
|
||||
|
||||
log::info!(
|
||||
"🔄 Running migration for pezpallet-welati from {:?} to {:?}",
|
||||
current,
|
||||
STORAGE_VERSION
|
||||
"🔄 Running migration for pezpallet-welati from {current:?} to {STORAGE_VERSION:?}"
|
||||
);
|
||||
|
||||
if current == StorageVersion::new(0) {
|
||||
let migrated;
|
||||
let mut weight = Weight::zero();
|
||||
|
||||
// Example migration logic for governance storage
|
||||
@@ -40,18 +41,14 @@ pub mod v1 {
|
||||
let elections_count = ActiveElections::<T>::iter().count() as u64;
|
||||
let proposals_count = ActiveProposals::<T>::iter().count() as u64;
|
||||
|
||||
migrated = officials_count + ministers_count + elections_count + proposals_count;
|
||||
let migrated = officials_count + ministers_count + elections_count + proposals_count;
|
||||
|
||||
// Update storage version
|
||||
STORAGE_VERSION.put::<Pezpallet<T>>();
|
||||
|
||||
log::info!("✅ Migrated {} entries in pezpallet-welati", migrated);
|
||||
log::info!("✅ Migrated {migrated} entries in pezpallet-welati");
|
||||
log::info!(
|
||||
" Officials: {}, Ministers: {}, Elections: {}, Proposals: {}",
|
||||
officials_count,
|
||||
ministers_count,
|
||||
elections_count,
|
||||
proposals_count
|
||||
" Officials: {officials_count}, Ministers: {ministers_count}, Elections: {elections_count}, Proposals: {proposals_count}"
|
||||
);
|
||||
|
||||
// Return weight used
|
||||
@@ -62,8 +59,7 @@ pub mod v1 {
|
||||
weight
|
||||
} else {
|
||||
log::info!(
|
||||
"👌 pezpallet-welati migration not needed, current version is {:?}",
|
||||
current
|
||||
"👌 pezpallet-welati migration not needed, current version is {current:?}"
|
||||
);
|
||||
T::DbWeight::get().reads(1)
|
||||
}
|
||||
@@ -74,7 +70,7 @@ pub mod v1 {
|
||||
let current = Pezpallet::<T>::on_chain_storage_version();
|
||||
|
||||
log::info!("🔍 Pre-upgrade check for pezpallet-welati");
|
||||
log::info!(" Current version: {:?}", current);
|
||||
log::info!(" Current version: {current:?}");
|
||||
|
||||
// Encode current storage counts for verification
|
||||
let officials_count = CurrentOfficials::<T>::iter().count() as u32;
|
||||
@@ -92,20 +88,20 @@ pub mod v1 {
|
||||
let proposals_count = ActiveProposals::<T>::iter().count() as u32;
|
||||
let collective_votes_count = CollectiveVotes::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(" CurrentOfficials entries: {}", officials_count);
|
||||
log::info!(" CurrentMinisters entries: {}", ministers_count);
|
||||
log::info!(" ParliamentMembers entries: {}", parliament_count);
|
||||
log::info!(" DiwanMembers entries: {}", diwan_count);
|
||||
log::info!(" AppointedOfficials entries: {}", appointed_count);
|
||||
log::info!(" ActiveElections entries: {}", elections_count);
|
||||
log::info!(" ElectionCandidates entries: {}", candidates_count);
|
||||
log::info!(" ElectionVotes entries: {}", votes_count);
|
||||
log::info!(" ElectionResults entries: {}", results_count);
|
||||
log::info!(" ElectoralDistrictConfig entries: {}", districts_count);
|
||||
log::info!(" PendingNominations entries: {}", nominations_count);
|
||||
log::info!(" AppointmentProcesses entries: {}", appointments_count);
|
||||
log::info!(" ActiveProposals entries: {}", proposals_count);
|
||||
log::info!(" CollectiveVotes entries: {}", collective_votes_count);
|
||||
log::info!(" CurrentOfficials entries: {officials_count}");
|
||||
log::info!(" CurrentMinisters entries: {ministers_count}");
|
||||
log::info!(" ParliamentMembers entries: {parliament_count}");
|
||||
log::info!(" DiwanMembers entries: {diwan_count}");
|
||||
log::info!(" AppointedOfficials entries: {appointed_count}");
|
||||
log::info!(" ActiveElections entries: {elections_count}");
|
||||
log::info!(" ElectionCandidates entries: {candidates_count}");
|
||||
log::info!(" ElectionVotes entries: {votes_count}");
|
||||
log::info!(" ElectionResults entries: {results_count}");
|
||||
log::info!(" ElectoralDistrictConfig entries: {districts_count}");
|
||||
log::info!(" PendingNominations entries: {nominations_count}");
|
||||
log::info!(" AppointmentProcesses entries: {appointments_count}");
|
||||
log::info!(" ActiveProposals entries: {proposals_count}");
|
||||
log::info!(" CollectiveVotes entries: {collective_votes_count}");
|
||||
|
||||
Ok((
|
||||
officials_count,
|
||||
@@ -147,7 +143,7 @@ pub mod v1 {
|
||||
pre_appointments_count,
|
||||
pre_proposals_count,
|
||||
pre_collective_votes_count,
|
||||
): (u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32) =
|
||||
): PreUpgradeState =
|
||||
Decode::decode(&mut &state[..])
|
||||
.map_err(|_| "Failed to decode pre-upgrade state")?;
|
||||
|
||||
@@ -156,7 +152,7 @@ pub mod v1 {
|
||||
// Verify storage version was updated
|
||||
let current_version = Pezpallet::<T>::on_chain_storage_version();
|
||||
assert_eq!(current_version, STORAGE_VERSION, "Storage version not updated correctly");
|
||||
log::info!("✅ Storage version updated to {:?}", current_version);
|
||||
log::info!("✅ Storage version updated to {current_version:?}");
|
||||
|
||||
// Verify storage counts (should be same or more, never less)
|
||||
let post_officials_count = CurrentOfficials::<T>::iter().count() as u32;
|
||||
@@ -174,68 +170,20 @@ pub mod v1 {
|
||||
let post_proposals_count = ActiveProposals::<T>::iter().count() as u32;
|
||||
let post_collective_votes_count = CollectiveVotes::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(
|
||||
" CurrentOfficials entries: {} -> {}",
|
||||
pre_officials_count,
|
||||
post_officials_count
|
||||
);
|
||||
log::info!(
|
||||
" CurrentMinisters entries: {} -> {}",
|
||||
pre_ministers_count,
|
||||
post_ministers_count
|
||||
);
|
||||
log::info!(
|
||||
" ParliamentMembers entries: {} -> {}",
|
||||
pre_parliament_count,
|
||||
post_parliament_count
|
||||
);
|
||||
log::info!(" DiwanMembers entries: {} -> {}", pre_diwan_count, post_diwan_count);
|
||||
log::info!(
|
||||
" AppointedOfficials entries: {} -> {}",
|
||||
pre_appointed_count,
|
||||
post_appointed_count
|
||||
);
|
||||
log::info!(
|
||||
" ActiveElections entries: {} -> {}",
|
||||
pre_elections_count,
|
||||
post_elections_count
|
||||
);
|
||||
log::info!(
|
||||
" ElectionCandidates entries: {} -> {}",
|
||||
pre_candidates_count,
|
||||
post_candidates_count
|
||||
);
|
||||
log::info!(" ElectionVotes entries: {} -> {}", pre_votes_count, post_votes_count);
|
||||
log::info!(
|
||||
" ElectionResults entries: {} -> {}",
|
||||
pre_results_count,
|
||||
post_results_count
|
||||
);
|
||||
log::info!(
|
||||
" ElectoralDistrictConfig entries: {} -> {}",
|
||||
pre_districts_count,
|
||||
post_districts_count
|
||||
);
|
||||
log::info!(
|
||||
" PendingNominations entries: {} -> {}",
|
||||
pre_nominations_count,
|
||||
post_nominations_count
|
||||
);
|
||||
log::info!(
|
||||
" AppointmentProcesses entries: {} -> {}",
|
||||
pre_appointments_count,
|
||||
post_appointments_count
|
||||
);
|
||||
log::info!(
|
||||
" ActiveProposals entries: {} -> {}",
|
||||
pre_proposals_count,
|
||||
post_proposals_count
|
||||
);
|
||||
log::info!(
|
||||
" CollectiveVotes entries: {} -> {}",
|
||||
pre_collective_votes_count,
|
||||
post_collective_votes_count
|
||||
);
|
||||
log::info!(" CurrentOfficials entries: {pre_officials_count} -> {post_officials_count}");
|
||||
log::info!(" CurrentMinisters entries: {pre_ministers_count} -> {post_ministers_count}");
|
||||
log::info!(" ParliamentMembers entries: {pre_parliament_count} -> {post_parliament_count}");
|
||||
log::info!(" DiwanMembers entries: {pre_diwan_count} -> {post_diwan_count}");
|
||||
log::info!(" AppointedOfficials entries: {pre_appointed_count} -> {post_appointed_count}");
|
||||
log::info!(" ActiveElections entries: {pre_elections_count} -> {post_elections_count}");
|
||||
log::info!(" ElectionCandidates entries: {pre_candidates_count} -> {post_candidates_count}");
|
||||
log::info!(" ElectionVotes entries: {pre_votes_count} -> {post_votes_count}");
|
||||
log::info!(" ElectionResults entries: {pre_results_count} -> {post_results_count}");
|
||||
log::info!(" ElectoralDistrictConfig entries: {pre_districts_count} -> {post_districts_count}");
|
||||
log::info!(" PendingNominations entries: {pre_nominations_count} -> {post_nominations_count}");
|
||||
log::info!(" AppointmentProcesses entries: {pre_appointments_count} -> {post_appointments_count}");
|
||||
log::info!(" ActiveProposals entries: {pre_proposals_count} -> {post_proposals_count}");
|
||||
log::info!(" CollectiveVotes entries: {pre_collective_votes_count} -> {post_collective_votes_count}");
|
||||
|
||||
// Verify no data was lost
|
||||
assert!(
|
||||
|
||||
@@ -10,6 +10,11 @@ use pezsp_runtime::{
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use pezsp_runtime::testing::{TestSignature, UintAuthorityId};
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use pezsp_runtime::RuntimeAppPublic;
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
type AccountId = u64;
|
||||
type Balance = u128;
|
||||
@@ -115,6 +120,28 @@ parameter_types! {
|
||||
pub const MaxAttributesPerCall: u32 = 1;
|
||||
}
|
||||
|
||||
// Custom BenchmarkHelper for pezpallet_nfts (uses u64 AccountId in mock)
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub struct NftsBenchmarkHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature> for NftsBenchmarkHelper {
|
||||
fn collection(i: u16) -> u32 {
|
||||
i.into()
|
||||
}
|
||||
fn item(i: u16) -> u32 {
|
||||
i.into()
|
||||
}
|
||||
fn signer() -> (UintAuthorityId, AccountId) {
|
||||
let signer = UintAuthorityId(0);
|
||||
let account: AccountId = 1u64;
|
||||
(signer, account)
|
||||
}
|
||||
fn sign(signer: &UintAuthorityId, data: &[u8]) -> TestSignature {
|
||||
<UintAuthorityId as RuntimeAppPublic>::sign(signer, &data.to_vec()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl pezpallet_nfts::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type CollectionId = u32;
|
||||
@@ -142,7 +169,7 @@ impl pezpallet_nfts::Config for Test {
|
||||
type WeightInfo = ();
|
||||
type BlockNumberProvider = System;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type Helper = ();
|
||||
type Helper = NftsBenchmarkHelper;
|
||||
}
|
||||
|
||||
// Identity Configuration - MINIMAL for pezpallet-tiki dependency
|
||||
@@ -160,6 +187,19 @@ parameter_types! {
|
||||
pub const UsernameGracePeriod: u64 = 100;
|
||||
}
|
||||
|
||||
// Custom BenchmarkHelper for pezpallet_identity (uses TestSignature in mock)
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub struct IdentityBenchmarkHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature> for IdentityBenchmarkHelper {
|
||||
fn sign_message(message: &[u8]) -> (UintAuthorityId, TestSignature) {
|
||||
let signer = UintAuthorityId(0);
|
||||
let signature = <UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
|
||||
(signer, signature)
|
||||
}
|
||||
}
|
||||
|
||||
impl pezpallet_identity::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
@@ -182,7 +222,7 @@ impl pezpallet_identity::Config for Test {
|
||||
type OffchainSignature = pezsp_runtime::testing::TestSignature;
|
||||
type SigningPublicKey = pezsp_runtime::testing::UintAuthorityId;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = ();
|
||||
type BenchmarkHelper = IdentityBenchmarkHelper;
|
||||
}
|
||||
|
||||
// Identity KYC Configuration
|
||||
@@ -218,7 +258,6 @@ impl pezpallet_identity_kyc::types::CitizenNftProvider<AccountId> for NoOpCitize
|
||||
}
|
||||
|
||||
impl pezpallet_identity_kyc::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type GovernanceOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type WeightInfo = ();
|
||||
@@ -246,7 +285,6 @@ impl pezpallet_staking_score::StakingInfoProvider<AccountId, Balance> for MockSt
|
||||
|
||||
// Staking Score Configuration
|
||||
impl pezpallet_staking_score::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Balance = Balance;
|
||||
type StakingInfo = MockStakingInfo;
|
||||
@@ -259,7 +297,6 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl pezpallet_referral::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type DefaultReferrer = DefaultReferrerAccount;
|
||||
type PenaltyPerRevocation = PenaltyPerRevocation;
|
||||
@@ -272,7 +309,6 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl pezpallet_tiki::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type AdminOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type WeightInfo = ();
|
||||
type MaxTikisPerUser = MaxTikisPerUser;
|
||||
@@ -348,7 +384,6 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl pezpallet_trust::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Score = u128;
|
||||
type ScoreMultiplierBase = ScoreMultiplierBase;
|
||||
@@ -375,7 +410,6 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl pezpallet_welati::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Randomness = MockRandomness;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
@@ -475,9 +509,3 @@ pub fn run_to_block(n: u64) {
|
||||
pub fn last_event() -> RuntimeEvent {
|
||||
System::events().pop().expect("Event expected").event
|
||||
}
|
||||
|
||||
pub fn events() -> Vec<RuntimeEvent> {
|
||||
let evt = System::events().into_iter().map(|evt| evt.event).collect::<Vec<_>>();
|
||||
System::reset_events();
|
||||
evt
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ fn calculate_vote_weight_works() {
|
||||
assert_eq!(Welati::calculate_vote_weight(&1, &ElectionType::Parliamentary), 1);
|
||||
|
||||
let weight = Welati::calculate_vote_weight(&1, &ElectionType::SpeakerElection);
|
||||
assert!(weight >= 1 && weight <= 10);
|
||||
assert!((1..=10).contains(&weight));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user