diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index 6a0c12c1c8af715dd298872e5b798dc6119976b9..b32f0b46b7e1c36b27ce7ac04c131f6aa55a6a8e 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -122,7 +122,7 @@ impl pallet_identity::Config for Test { type ChangeOwnerKeyPeriod = ChangeOwnerKeyPeriod; type ConfirmPeriod = ConfirmPeriod; type Event = Event; - type EnsureIdtyCallAllowed = DuniterWot; + type EnsureIdtyCallAllowed = (DuniterWot, SmithsSubWot); type IdtyCreationPeriod = IdtyCreationPeriod; type IdtyData = (); type IdtyNameValidator = IdtyNameValidatorTestImpl; diff --git a/pallets/duniter-wot/src/tests.rs b/pallets/duniter-wot/src/tests.rs index 3cb3da2b9eabd3426e6a4100525c4ef4648ff380..8ff6dddba8d378b8bdfa0b7adcb9e94e833aa70e 100644 --- a/pallets/duniter-wot/src/tests.rs +++ b/pallets/duniter-wot/src/tests.rs @@ -16,11 +16,12 @@ use crate::mock::*; use crate::mock::{Identity, System}; -use frame_support::assert_noop; -use frame_support::assert_ok; +use codec::Encode; use frame_support::instances::Instance1; +use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; -use pallet_identity::{IdtyName, IdtyStatus}; +use pallet_identity::{IdtyName, IdtyStatus, NewOwnerKeyPayload, NEW_OWNER_KEY_PAYLOAD_PREFIX}; +use sp_runtime::testing::TestSignature; #[test] fn test_genesis_build() { @@ -92,6 +93,30 @@ fn test_smith_certs_expirations_should_revoke_smith_membership() { }); } +#[test] +fn test_smith_member_cant_change_idty_address() { + new_test_ext(5, 3).execute_with(|| { + run_to_block(2); + + let genesis_hash = System::block_hash(0); + let new_key_payload = NewOwnerKeyPayload { + genesis_hash: &genesis_hash, + idty_index: 3u32, + old_owner_key: &3u64, + }; + + // Identity 3 can't change it's address + assert_noop!( + Identity::change_owner_key( + Origin::signed(3), + 13, + TestSignature(13, (NEW_OWNER_KEY_PAYLOAD_PREFIX, new_key_payload).encode()) + ), + pallet_identity::Error::<Test>::NotAllowedToChangeIdtyAddress + ); + }); +} + #[test] fn test_revoke_smiths_them_rejoin() { new_test_ext(5, 4).execute_with(|| {