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:
@@ -10,7 +10,6 @@ use pezframe_support::traits::{Currency, Get};
|
||||
use pezpallet_balances::Pezpallet as Balances;
|
||||
use pezsp_runtime::traits::StaticLookup;
|
||||
extern crate alloc;
|
||||
use alloc::vec;
|
||||
|
||||
// Gerekli trait kısıtlamalarını ana benchmarks bloğuna ekliyoruz.
|
||||
#[benchmarks(
|
||||
@@ -22,10 +21,9 @@ mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
// Bu yardımcı fonksiyon, runtime'da tanımlanan Tiki koleksiyonunu oluşturur.
|
||||
fn ensure_collection_exists<T: Config>()
|
||||
fn ensure_collection_exists<T: Config + pezpallet_balances::Config>()
|
||||
where
|
||||
T::CollectionId: Copy + Default + PartialOrd,
|
||||
T: pezpallet_balances::Config,
|
||||
T::CollectionId: Default + PartialOrd,
|
||||
{
|
||||
let collection_id = T::TikiCollectionId::get();
|
||||
// Koleksiyon sahibi olarak fonlanmış `whitelisted_caller`'ı kullanıyoruz.
|
||||
@@ -51,10 +49,9 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
// Helper to ensure user has a citizen NFT
|
||||
fn ensure_citizen_nft<T: Config>(who: T::AccountId) -> Result<(), DispatchError>
|
||||
fn ensure_citizen_nft<T: Config + pezpallet_balances::Config>(who: T::AccountId) -> Result<(), DispatchError>
|
||||
where
|
||||
T::CollectionId: Copy + Default + PartialOrd,
|
||||
T: pezpallet_balances::Config,
|
||||
T::CollectionId: Default + PartialOrd,
|
||||
{
|
||||
ensure_collection_exists::<T>();
|
||||
|
||||
@@ -80,7 +77,7 @@ mod benchmarks {
|
||||
ensure_citizen_nft::<T>(dest.clone())?;
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki.clone());
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki);
|
||||
|
||||
// For non-unique roles, check user has the role
|
||||
assert!(Tiki::<T>::user_tikis(&dest).contains(&tiki));
|
||||
@@ -95,13 +92,13 @@ mod benchmarks {
|
||||
|
||||
// Ensure the dest account has a citizen NFT and the tiki before revoking
|
||||
ensure_citizen_nft::<T>(dest.clone())?;
|
||||
Tiki::<T>::internal_grant_role(&dest, tiki.clone())?; // Use internal function to grant without origin check
|
||||
Tiki::<T>::internal_grant_role(&dest, tiki)?; // Use internal function to grant without origin check
|
||||
|
||||
// Verify the role was granted
|
||||
assert!(Tiki::<T>::user_tikis(&dest).contains(&tiki));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki.clone());
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki);
|
||||
|
||||
// User should no longer have this role
|
||||
assert!(!Tiki::<T>::user_tikis(&dest).contains(&tiki));
|
||||
@@ -137,7 +134,7 @@ mod benchmarks {
|
||||
ensure_citizen_nft::<T>(dest.clone())?;
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki.clone());
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki);
|
||||
|
||||
// Rolün verildiğini doğrula
|
||||
assert!(Tiki::<T>::has_tiki(&dest, &tiki));
|
||||
@@ -154,7 +151,7 @@ mod benchmarks {
|
||||
ensure_citizen_nft::<T>(dest.clone())?;
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki.clone());
|
||||
_(RawOrigin::Root, T::Lookup::unlookup(dest.clone()), tiki);
|
||||
|
||||
// Rolün verildiğini doğrula
|
||||
assert!(Tiki::<T>::has_tiki(&dest, &tiki));
|
||||
|
||||
@@ -133,12 +133,10 @@ pub mod pezpallet {
|
||||
|
||||
#[pezpallet::config]
|
||||
pub trait Config:
|
||||
pezframe_system::Config
|
||||
pezframe_system::Config<RuntimeEvent: From<Event<Self>>>
|
||||
+ pezpallet_nfts::Config<ItemId = u32>
|
||||
+ pezpallet_identity_kyc::Config
|
||||
{
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type AdminOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
type WeightInfo: weights::WeightInfo;
|
||||
|
||||
@@ -480,7 +478,7 @@ pub mod pezpallet {
|
||||
if Self::citizen_nft(&account).is_none() {
|
||||
// Mint NFT (log error but continue on failure)
|
||||
if Self::mint_citizen_nft_for_user(&account).is_err() {
|
||||
log::warn!("Failed to mint citizen NFT for account: {:?}", account);
|
||||
log::warn!("Failed to mint citizen NFT for account: {account:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -661,7 +659,7 @@ pub mod pezpallet {
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
log::warn!("Failed to set metadata for NFT: {:?}", nft_id_u32);
|
||||
log::warn!("Failed to set metadata for NFT: {nft_id_u32:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -22,9 +22,7 @@ pub mod v1 {
|
||||
let current = Pezpallet::<T>::on_chain_storage_version();
|
||||
|
||||
log::info!(
|
||||
"🔄 Running migration for pezpallet-tiki from {:?} to {:?}",
|
||||
current,
|
||||
STORAGE_VERSION
|
||||
"🔄 Running migration for pezpallet-tiki from {current:?} to {STORAGE_VERSION:?}"
|
||||
);
|
||||
|
||||
if current == StorageVersion::new(0) {
|
||||
@@ -43,7 +41,7 @@ pub mod v1 {
|
||||
// Update storage version
|
||||
STORAGE_VERSION.put::<Pezpallet<T>>();
|
||||
|
||||
log::info!("✅ Migrated {} entries in pezpallet-tiki", migrated);
|
||||
log::info!("✅ Migrated {migrated} entries in pezpallet-tiki");
|
||||
|
||||
// Return weight used
|
||||
// Reads: migrated items + version read
|
||||
@@ -54,8 +52,7 @@ pub mod v1 {
|
||||
weight
|
||||
} else {
|
||||
log::info!(
|
||||
"👌 pezpallet-tiki migration not needed, current version is {:?}",
|
||||
current
|
||||
"👌 pezpallet-tiki migration not needed, current version is {current:?}"
|
||||
);
|
||||
T::DbWeight::get().reads(1)
|
||||
}
|
||||
@@ -68,16 +65,16 @@ pub mod v1 {
|
||||
let current = Pezpallet::<T>::on_chain_storage_version();
|
||||
|
||||
log::info!("🔍 Pre-upgrade check for pezpallet-tiki");
|
||||
log::info!(" Current version: {:?}", current);
|
||||
log::info!(" Current version: {current:?}");
|
||||
|
||||
// Encode current storage counts for verification
|
||||
let citizen_count = CitizenNft::<T>::iter().count() as u32;
|
||||
let user_tikis_count = UserTikis::<T>::iter().count() as u32;
|
||||
let tiki_holder_count = TikiHolder::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(" CitizenNft entries: {}", citizen_count);
|
||||
log::info!(" UserTikis entries: {}", user_tikis_count);
|
||||
log::info!(" TikiHolder entries: {}", tiki_holder_count);
|
||||
log::info!(" CitizenNft entries: {citizen_count}");
|
||||
log::info!(" UserTikis entries: {user_tikis_count}");
|
||||
log::info!(" TikiHolder entries: {tiki_holder_count}");
|
||||
|
||||
Ok((citizen_count, user_tikis_count, tiki_holder_count).encode())
|
||||
}
|
||||
@@ -96,23 +93,19 @@ 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_citizen_count = CitizenNft::<T>::iter().count() as u32;
|
||||
let post_user_tikis_count = UserTikis::<T>::iter().count() as u32;
|
||||
let post_tiki_holder_count = TikiHolder::<T>::iter().count() as u32;
|
||||
|
||||
log::info!(" CitizenNft entries: {} -> {}", pre_citizen_count, post_citizen_count);
|
||||
log::info!(" CitizenNft entries: {pre_citizen_count} -> {post_citizen_count}");
|
||||
log::info!(
|
||||
" UserTikis entries: {} -> {}",
|
||||
pre_user_tikis_count,
|
||||
post_user_tikis_count
|
||||
" UserTikis entries: {pre_user_tikis_count} -> {post_user_tikis_count}"
|
||||
);
|
||||
log::info!(
|
||||
" TikiHolder entries: {} -> {}",
|
||||
pre_tiki_holder_count,
|
||||
post_tiki_holder_count
|
||||
" TikiHolder entries: {pre_tiki_holder_count} -> {post_tiki_holder_count}"
|
||||
);
|
||||
|
||||
assert!(
|
||||
|
||||
@@ -10,6 +10,46 @@ use pezsp_runtime::{
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use pezsp_runtime::testing::{TestSignature, UintAuthorityId};
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use pezsp_runtime::RuntimeAppPublic;
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
// 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).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
pub type AccountId = u64;
|
||||
pub type Balance = u128;
|
||||
@@ -113,6 +153,8 @@ impl pezpallet_identity::Config for Test {
|
||||
type UsernameGracePeriod = UsernameGracePeriod;
|
||||
type MaxSuffixLength = MaxSuffixLength;
|
||||
type MaxUsernameLength = MaxUsernameLength;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = IdentityBenchmarkHelper;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -158,7 +200,6 @@ impl pezpallet_identity_kyc::types::CitizenNftProvider<AccountId> for MockCitize
|
||||
}
|
||||
|
||||
impl pezpallet_identity_kyc::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type WeightInfo = ();
|
||||
type GovernanceOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
@@ -197,11 +238,11 @@ impl pezpallet_nfts::Config for Test {
|
||||
type MaxAttributesPerCall = ConstU32<10>;
|
||||
type Features = Features;
|
||||
type OffchainSignature = pezsp_runtime::testing::TestSignature;
|
||||
type OffchainPublic = <Self::OffchainSignature as pezsp_runtime::traits::Verify>::Signer;
|
||||
type OffchainPublic = pezsp_runtime::testing::UintAuthorityId;
|
||||
type WeightInfo = ();
|
||||
type BlockNumberProvider = System;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type Helper = ();
|
||||
type Helper = NftsBenchmarkHelper;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -210,7 +251,6 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl crate::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type AdminOrigin = pezframe_system::EnsureRoot<AccountId>;
|
||||
type WeightInfo = ();
|
||||
type TikiCollectionId = TikiCollectionId;
|
||||
@@ -218,43 +258,6 @@ impl crate::Config for Test {
|
||||
type Tiki = TikiEnum;
|
||||
}
|
||||
|
||||
// Helper functions for tests
|
||||
// Updated for trustless model - directly sets KYC status and hash
|
||||
pub fn setup_kyc_for_user(account: AccountId) {
|
||||
// Give balance to user
|
||||
let _ = Balances::force_set_balance(RuntimeOrigin::root(), account, 10000);
|
||||
|
||||
// Directly set KYC status to Approved (for test purposes)
|
||||
// In real runtime this would go through apply_for_citizenship -> approve_referral ->
|
||||
// confirm_citizenship
|
||||
pezpallet_identity_kyc::KycStatuses::<Test>::insert(
|
||||
account,
|
||||
pezpallet_identity_kyc::types::KycLevel::Approved,
|
||||
);
|
||||
|
||||
// Set identity hash
|
||||
pezpallet_identity_kyc::IdentityHashes::<Test>::insert(
|
||||
account,
|
||||
pezsp_core::H256::from_low_u64_be(account),
|
||||
);
|
||||
}
|
||||
|
||||
// Legacy function - kept for backwards compatibility
|
||||
pub fn setup_identity_for_user(account: AccountId) {
|
||||
setup_kyc_for_user(account);
|
||||
}
|
||||
|
||||
pub fn advance_blocks(blocks: u64) {
|
||||
for _i in 0..blocks {
|
||||
let current_block = System::block_number();
|
||||
System::set_block_number(current_block + 1);
|
||||
// Trigger hooks for the new block
|
||||
<pezpallet_tiki::Pezpallet<Test> as pezframe_support::traits::Hooks<u64>>::on_initialize(
|
||||
current_block + 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
|
||||
|
||||
@@ -14,17 +14,17 @@ fn force_mint_citizen_nft_works() {
|
||||
let user_account = 2;
|
||||
|
||||
// Başlangıçta vatandaşlık NFT'si olmamalı
|
||||
assert_eq!(TikiPallet::citizen_nft(&user_account), None);
|
||||
assert!(TikiPallet::user_tikis(&user_account).is_empty());
|
||||
assert_eq!(TikiPallet::citizen_nft(user_account), None);
|
||||
assert!(TikiPallet::user_tikis(user_account).is_empty());
|
||||
assert!(!TikiPallet::is_citizen(&user_account));
|
||||
|
||||
// Vatandaşlık NFT'si bas
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
|
||||
|
||||
// NFT'nin basıldığını ve Welati rolünün eklendiğini kontrol et
|
||||
assert!(TikiPallet::citizen_nft(&user_account).is_some());
|
||||
assert!(TikiPallet::citizen_nft(user_account).is_some());
|
||||
assert!(TikiPallet::is_citizen(&user_account));
|
||||
let user_tikis = TikiPallet::user_tikis(&user_account);
|
||||
let user_tikis = TikiPallet::user_tikis(user_account);
|
||||
assert!(user_tikis.contains(&TikiEnum::Welati));
|
||||
assert!(TikiPallet::has_tiki(&user_account, &TikiEnum::Welati));
|
||||
|
||||
@@ -32,7 +32,7 @@ fn force_mint_citizen_nft_works() {
|
||||
System::assert_has_event(
|
||||
Event::CitizenNftMinted {
|
||||
who: user_account,
|
||||
nft_id: TikiPallet::citizen_nft(&user_account).unwrap(),
|
||||
nft_id: TikiPallet::citizen_nft(user_account).unwrap(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
@@ -52,11 +52,11 @@ fn grant_appointed_role_works() {
|
||||
assert_ok!(TikiPallet::grant_tiki(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
tiki_to_grant.clone()
|
||||
tiki_to_grant
|
||||
));
|
||||
|
||||
// Kullanıcının rollerini kontrol et
|
||||
let user_tikis = TikiPallet::user_tikis(&user_account);
|
||||
let user_tikis = TikiPallet::user_tikis(user_account);
|
||||
assert!(user_tikis.contains(&TikiEnum::Welati)); // Otomatik eklenen
|
||||
assert!(user_tikis.contains(&tiki_to_grant)); // Manuel eklenen
|
||||
assert!(TikiPallet::has_tiki(&user_account, &tiki_to_grant));
|
||||
@@ -97,8 +97,8 @@ fn apply_for_citizenship_works_with_kyc() {
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
|
||||
|
||||
// NFT'nin basıldığını kontrol et
|
||||
assert!(TikiPallet::citizen_nft(&user_account).is_some());
|
||||
assert!(TikiPallet::user_tikis(&user_account).contains(&TikiEnum::Welati));
|
||||
assert!(TikiPallet::citizen_nft(user_account).is_some());
|
||||
assert!(TikiPallet::user_tikis(user_account).contains(&TikiEnum::Welati));
|
||||
assert!(TikiPallet::is_citizen(&user_account));
|
||||
});
|
||||
}
|
||||
@@ -126,7 +126,7 @@ fn auto_grant_citizenship_simplified() {
|
||||
assert_ok!(TikiPallet::auto_grant_citizenship(&user));
|
||||
|
||||
// KYC olmadığı için NFT basılmamalı
|
||||
assert!(TikiPallet::citizen_nft(&user).is_none());
|
||||
assert!(TikiPallet::citizen_nft(user).is_none());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,11 +192,11 @@ fn grant_earned_role_works() {
|
||||
assert_ok!(TikiPallet::grant_earned_role(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
earned_role.clone()
|
||||
earned_role
|
||||
));
|
||||
|
||||
// Rolün eklendiğini kontrol et
|
||||
assert!(TikiPallet::user_tikis(&user_account).contains(&earned_role));
|
||||
assert!(TikiPallet::user_tikis(user_account).contains(&earned_role));
|
||||
assert!(TikiPallet::has_tiki(&user_account, &earned_role));
|
||||
});
|
||||
}
|
||||
@@ -214,11 +214,11 @@ fn grant_elected_role_works() {
|
||||
assert_ok!(TikiPallet::grant_elected_role(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
elected_role.clone()
|
||||
elected_role
|
||||
));
|
||||
|
||||
// Rolün eklendiğini kontrol et
|
||||
assert!(TikiPallet::user_tikis(&user_account).contains(&elected_role));
|
||||
assert!(TikiPallet::user_tikis(user_account).contains(&elected_role));
|
||||
assert!(TikiPallet::has_tiki(&user_account, &elected_role));
|
||||
});
|
||||
}
|
||||
@@ -240,17 +240,17 @@ fn unique_roles_work_correctly() {
|
||||
assert_ok!(TikiPallet::grant_elected_role(
|
||||
RuntimeOrigin::root(),
|
||||
user1,
|
||||
unique_role.clone()
|
||||
unique_role
|
||||
));
|
||||
|
||||
// İkinci kullanıcıya aynı rolü vermeye çalış
|
||||
assert_noop!(
|
||||
TikiPallet::grant_elected_role(RuntimeOrigin::root(), user2, unique_role.clone()),
|
||||
TikiPallet::grant_elected_role(RuntimeOrigin::root(), user2, unique_role),
|
||||
Error::<Test>::RoleAlreadyTaken
|
||||
);
|
||||
|
||||
// TikiHolder'da doğru şekilde kaydedildiğini kontrol et
|
||||
assert_eq!(TikiPallet::tiki_holder(&unique_role), Some(user1));
|
||||
assert_eq!(TikiPallet::tiki_holder(unique_role), Some(user1));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -282,24 +282,24 @@ fn revoke_tiki_works() {
|
||||
assert_ok!(TikiPallet::grant_tiki(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
tiki_to_revoke.clone()
|
||||
tiki_to_revoke
|
||||
));
|
||||
|
||||
// Rolün eklendiğini kontrol et
|
||||
assert!(TikiPallet::user_tikis(&user_account).contains(&tiki_to_revoke));
|
||||
assert!(TikiPallet::user_tikis(user_account).contains(&tiki_to_revoke));
|
||||
|
||||
// Rolü kaldır
|
||||
assert_ok!(TikiPallet::revoke_tiki(
|
||||
RuntimeOrigin::root(),
|
||||
user_account,
|
||||
tiki_to_revoke.clone()
|
||||
tiki_to_revoke
|
||||
));
|
||||
|
||||
// Rolün kaldırıldığını kontrol et
|
||||
assert!(!TikiPallet::user_tikis(&user_account).contains(&tiki_to_revoke));
|
||||
assert!(!TikiPallet::user_tikis(user_account).contains(&tiki_to_revoke));
|
||||
assert!(!TikiPallet::has_tiki(&user_account, &tiki_to_revoke));
|
||||
// Welati rolünün hala durduğunu kontrol et
|
||||
assert!(TikiPallet::user_tikis(&user_account).contains(&TikiEnum::Welati));
|
||||
assert!(TikiPallet::user_tikis(user_account).contains(&TikiEnum::Welati));
|
||||
|
||||
// Event kontrol et
|
||||
System::assert_has_event(
|
||||
@@ -335,18 +335,18 @@ fn revoke_unique_role_clears_holder() {
|
||||
assert_ok!(TikiPallet::grant_elected_role(
|
||||
RuntimeOrigin::root(),
|
||||
user,
|
||||
unique_role.clone()
|
||||
unique_role
|
||||
));
|
||||
|
||||
// TikiHolder'da kayıtlı olduğunu kontrol et
|
||||
assert_eq!(TikiPallet::tiki_holder(&unique_role), Some(user));
|
||||
assert_eq!(TikiPallet::tiki_holder(unique_role), Some(user));
|
||||
|
||||
// Rolü kaldır
|
||||
assert_ok!(TikiPallet::revoke_tiki(RuntimeOrigin::root(), user, unique_role.clone()));
|
||||
assert_ok!(TikiPallet::revoke_tiki(RuntimeOrigin::root(), user, unique_role));
|
||||
|
||||
// TikiHolder'dan temizlendiğini kontrol et
|
||||
assert_eq!(TikiPallet::tiki_holder(&unique_role), None);
|
||||
assert!(!TikiPallet::user_tikis(&user).contains(&unique_role));
|
||||
assert_eq!(TikiPallet::tiki_holder(unique_role), None);
|
||||
assert!(!TikiPallet::user_tikis(user).contains(&unique_role));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -446,11 +446,11 @@ fn multiple_users_work_independently() {
|
||||
assert_eq!(TikiPallet::get_tiki_score(&user2), 110); // 10 + 100
|
||||
|
||||
// Rollerin doğru dağıldığını kontrol et
|
||||
assert!(TikiPallet::user_tikis(&user1).contains(&TikiEnum::Axa));
|
||||
assert!(!TikiPallet::user_tikis(&user1).contains(&TikiEnum::Wezir));
|
||||
assert!(TikiPallet::user_tikis(user1).contains(&TikiEnum::Axa));
|
||||
assert!(!TikiPallet::user_tikis(user1).contains(&TikiEnum::Wezir));
|
||||
|
||||
assert!(TikiPallet::user_tikis(&user2).contains(&TikiEnum::Wezir));
|
||||
assert!(!TikiPallet::user_tikis(&user2).contains(&TikiEnum::Axa));
|
||||
assert!(TikiPallet::user_tikis(user2).contains(&TikiEnum::Wezir));
|
||||
assert!(!TikiPallet::user_tikis(user2).contains(&TikiEnum::Axa));
|
||||
|
||||
// TikiProvider trait testleri
|
||||
assert!(TikiPallet::has_tiki(&user1, &TikiEnum::Axa));
|
||||
@@ -477,11 +477,11 @@ fn cannot_grant_role_without_citizen_nft() {
|
||||
#[test]
|
||||
fn nft_id_increments_correctly() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let users = vec![2, 3, 4];
|
||||
let users = [2, 3, 4];
|
||||
|
||||
for (i, user) in users.iter().enumerate() {
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), *user));
|
||||
assert_eq!(TikiPallet::citizen_nft(user), Some(i as u32));
|
||||
assert_eq!(TikiPallet::citizen_nft(*user), Some(i as u32));
|
||||
}
|
||||
|
||||
// Next ID'nin doğru arttığını kontrol et
|
||||
@@ -497,7 +497,7 @@ fn duplicate_roles_not_allowed() {
|
||||
|
||||
// NFT bas ve rol ver
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user));
|
||||
assert_ok!(TikiPallet::grant_earned_role(RuntimeOrigin::root(), user, role.clone()));
|
||||
assert_ok!(TikiPallet::grant_earned_role(RuntimeOrigin::root(), user, role));
|
||||
|
||||
// Aynı rolü tekrar vermeye çalış
|
||||
assert_noop!(
|
||||
@@ -628,7 +628,7 @@ fn complex_multi_role_scenario() {
|
||||
)); // Elected
|
||||
|
||||
// Tüm rollerin eklendiğini kontrol et
|
||||
let user_tikis = TikiPallet::user_tikis(&user);
|
||||
let user_tikis = TikiPallet::user_tikis(user);
|
||||
assert!(user_tikis.contains(&TikiEnum::Welati)); // 10 puan
|
||||
assert!(user_tikis.contains(&TikiEnum::Wezir)); // 100 puan
|
||||
assert!(user_tikis.contains(&TikiEnum::Mamoste)); // 70 puan
|
||||
@@ -753,8 +753,8 @@ fn stress_test_multiple_users_roles() {
|
||||
assert_eq!(TikiPallet::get_tiki_score(&5), 410); // 10 + 250 + 150
|
||||
|
||||
// Unique rollerin doğru atandığını kontrol et
|
||||
assert_eq!(TikiPallet::tiki_holder(&TikiEnum::Serok), Some(2));
|
||||
assert_eq!(TikiPallet::tiki_holder(&TikiEnum::SerokiMeclise), Some(4));
|
||||
assert_eq!(TikiPallet::tiki_holder(TikiEnum::Serok), Some(2));
|
||||
assert_eq!(TikiPallet::tiki_holder(TikiEnum::SerokiMeclise), Some(4));
|
||||
|
||||
// Toplam vatandaş sayısını kontrol et
|
||||
let mut citizen_count = 0;
|
||||
@@ -793,7 +793,7 @@ fn maximum_roles_per_user_limit() {
|
||||
}
|
||||
|
||||
// Kullanıcının pek çok role sahip olduğunu kontrol et
|
||||
let final_tikis = TikiPallet::user_tikis(&user);
|
||||
let final_tikis = TikiPallet::user_tikis(user);
|
||||
assert!(final_tikis.len() >= 5); // En az 5 rol olmalı (Welati + 4+ diğer)
|
||||
assert!(final_tikis.len() <= 100); // Max limit'i aşmamalı
|
||||
|
||||
@@ -836,7 +836,7 @@ fn apply_for_citizenship_adds_hemwelati() {
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user));
|
||||
|
||||
// Welati rolü var
|
||||
let tikis = TikiPallet::user_tikis(&user);
|
||||
let tikis = TikiPallet::user_tikis(user);
|
||||
assert!(tikis.contains(&TikiEnum::Welati));
|
||||
});
|
||||
}
|
||||
@@ -894,7 +894,7 @@ fn revoke_tiki_reduces_score() {
|
||||
assert!(final_score < initial_score);
|
||||
|
||||
// Rol listesinde yok
|
||||
let tikis = TikiPallet::user_tikis(&user);
|
||||
let tikis = TikiPallet::user_tikis(user);
|
||||
assert!(!tikis.contains(&TikiEnum::Dadger));
|
||||
});
|
||||
}
|
||||
@@ -998,14 +998,14 @@ fn user_tikis_updated_after_grant() {
|
||||
|
||||
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user));
|
||||
|
||||
let tikis_before = TikiPallet::user_tikis(&user);
|
||||
let tikis_before = TikiPallet::user_tikis(user);
|
||||
assert_eq!(tikis_before.len(), 1); // Only Welati
|
||||
|
||||
// Rol ekle
|
||||
assert_ok!(TikiPallet::grant_tiki(RuntimeOrigin::root(), user, TikiEnum::Dadger));
|
||||
|
||||
// UserTikis güncellendi
|
||||
let tikis_after = TikiPallet::user_tikis(&user);
|
||||
let tikis_after = TikiPallet::user_tikis(user);
|
||||
assert_eq!(tikis_after.len(), 2);
|
||||
assert!(tikis_after.contains(&TikiEnum::Dadger));
|
||||
});
|
||||
@@ -1021,7 +1021,7 @@ fn user_tikis_consistent_with_score() {
|
||||
assert_ok!(TikiPallet::grant_tiki(RuntimeOrigin::root(), user, TikiEnum::Wezir));
|
||||
|
||||
// UserTikis sayısı ile score tutarlı olmalı
|
||||
let user_tikis = TikiPallet::user_tikis(&user);
|
||||
let user_tikis = TikiPallet::user_tikis(user);
|
||||
let score = TikiPallet::get_tiki_score(&user);
|
||||
|
||||
assert_eq!(user_tikis.len(), 3); // Welati + Dadger + Wezir
|
||||
@@ -1042,8 +1042,8 @@ fn multiple_users_independent_roles() {
|
||||
assert_ok!(TikiPallet::grant_tiki(RuntimeOrigin::root(), user2, TikiEnum::Wezir));
|
||||
|
||||
// Roller bağımsız
|
||||
let tikis1 = TikiPallet::user_tikis(&user1);
|
||||
let tikis2 = TikiPallet::user_tikis(&user2);
|
||||
let tikis1 = TikiPallet::user_tikis(user1);
|
||||
let tikis2 = TikiPallet::user_tikis(user2);
|
||||
|
||||
assert!(tikis1.contains(&TikiEnum::Dadger));
|
||||
assert!(!tikis1.contains(&TikiEnum::Wezir));
|
||||
|
||||
Reference in New Issue
Block a user