Files
pezkuwi-sdk/pezcumulus/teyrchains/pezpallets/perwerde/src/mock.rs
T
pezkuwichain bd454cf395 feat: wire trust score system with cross-chain staking data and component triggers
- Add CachedStakingDetails storage and receive_staking_details extrinsic
  to staking-score pallet for Asset Hub XCM data reception
- Add TrustScoreUpdater triggers to referral, tiki, and perwerde pallets
  so component score changes propagate to trust pallet
- Wire runtime hooks (OnKycApproved, OnCitizenshipRevoked) to Referral
  and CitizenNftProvider to Tiki in people.rs
- Fix PerwerdeScoreSource and ReferralScoreSource to read actual pallet data
- Fix EnsureOrigin trait feature unification issue by removing cfg gate
  from try_successful_origin and adding default Err(()) implementation
- Fix workspace Cargo.toml default-features for pezkuwi-subxt dependencies
2026-02-13 20:13:50 +03:00

149 lines
4.8 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
use crate as pezpallet_perwerde;
use pezframe_support::{
construct_runtime, parameter_types,
traits::{ConstU128, ConstU16, ConstU32, ConstU64, Everything, SortedMembers},
};
use pezframe_system::EnsureRoot;
use pezsp_core::H256;
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
// Temel tipleri tanımlıyoruz.
pub type AccountId = u64;
pub type Balance = u128;
pub type BlockNumber = u64;
pub type Block = pezframe_system::mocking::MockBlock<Test>;
// Test runtime'ımızı kuruyoruz.
construct_runtime!(
pub enum Test
{
System: pezframe_system,
Balances: pezpallet_balances,
Perwerde: pezpallet_perwerde,
Council: pezpallet_collective::<Instance1>,
}
);
// pezframe_system için implementasyon.
impl pezframe_system::Config for Test {
type BaseCallFilter = Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pezpallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = ();
type ExtensionsWeightInfo = ();
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}
// pezpallet_balances için implementasyon.
impl pezpallet_balances::Config for Test {
type Balance = Balance;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ConstU128<1>;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ConstU32<50>;
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
type DoneSlashHandler = ();
}
parameter_types! {
pub const MaxCourseNameLength: u32 = 100;
pub const MaxCourseDescLength: u32 = 500;
pub const MaxCourseLinkLength: u32 = 200;
pub const MaxStudentsPerCourse: u32 = 100; // Reduced for test performance
pub const MaxCoursesPerStudent: u32 = 50; // Max courses a student can enroll in
}
// --- KESİN ÇÖZÜM BURADA BAŞLIYOR ---
// AdminOrigin'i test etmek için kendi özel yetki sağlayıcımızı oluşturuyoruz.
use pezframe_system::EnsureSignedBy;
// Bu struct, derleyicinin talep ettiği `SortedMembers` trait'ini manuel olarak uygular.
// Bu, harici ve versiyona bağımlı araçlara olan ihtiyacı ortadan kaldırır.
pub struct TestAdminProvider;
impl SortedMembers<AccountId> for TestAdminProvider {
fn sorted_members() -> Vec<AccountId> {
// Test için admin olarak sadece 0 ID'li hesabı yetkili kılıyoruz.
vec![0]
}
}
impl pezpallet_perwerde::Config for Test {
// AdminOrigin'i, kendi yazdığımız ve sadece 0'ı admin kabul eden sağlayıcıya bağlıyoruz.
type AdminOrigin = EnsureSignedBy<TestAdminProvider, AccountId>;
type WeightInfo = ();
type MaxCourseNameLength = MaxCourseNameLength;
type MaxCourseDescLength = MaxCourseDescLength;
type MaxCourseLinkLength = MaxCourseLinkLength;
type MaxStudentsPerCourse = MaxStudentsPerCourse;
type MaxCoursesPerStudent = MaxCoursesPerStudent;
type TrustScoreUpdater = ();
}
// Council Paletinin Mock Kurulumu (construct_runtime'da gerekli olduğu için kalıyor)
use pezpallet_collective::Instance1;
parameter_types! {
pub const CouncilMotionDuration: BlockNumber = 5 * 60; // 5 minutes
pub const CouncilMaxProposals: u32 = 100;
pub const CouncilMaxMembers: u32 = 100;
pub MaxProposalWeight: pezframe_support::weights::Weight = pezframe_support::weights::Weight::from_parts(1_000_000_000, 0);
}
impl pezpallet_collective::Config<Instance1> for Test {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = CouncilMotionDuration;
type MaxProposals = CouncilMaxProposals;
type MaxMembers = CouncilMaxMembers;
type DefaultVote = pezpallet_collective::PrimeDefaultVote;
type WeightInfo = ();
type SetMembersOrigin = EnsureRoot<AccountId>;
type MaxProposalWeight = MaxProposalWeight;
type DisapproveOrigin = EnsureRoot<AccountId>;
type KillOrigin = EnsureRoot<AccountId>;
type Consideration = ();
}
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
// `pezpallet-collective`'in genesis'ini de kurmamıza gerek kalmadı çünkü artık testimiz ona
// bağlı değil.
let mut ext = pezsp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}