From 0dcbcae8d0e9e30b55bb49f744378da56372846a Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Tue, 18 Feb 2025 21:09:53 +0100 Subject: [PATCH] reproduce #291 --- runtime/gdev/tests/integration_tests.rs | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 911d2be7e..9ee556b32 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -1499,6 +1499,35 @@ fn test_link_account() { }) } +/// test change owner key +#[test] +fn test_change_owner_key_validator_keys_set() { + ExtBuilder::new(1, 3, 4).build().execute_with(|| { + let genesis_hash = System::block_hash(0); + let bob = AccountKeyring::Bob.to_account_id(); + let ferdie = AccountKeyring::Ferdie.to_account_id(); + let payload = (b"icok", genesis_hash, 2u32, bob.clone()).encode(); + let signature = AccountKeyring::Bob.sign(&payload); + + // Bob is not an online validator, but his identity/owner_key is already associated. + // He should not be able to change its owner_key. + assert_ok!(AuthorityMembers::go_online(RuntimeOrigin::signed( + AccountKeyring::Bob.to_account_id() + ))); + assert!(!pallet_authority_members::OnlineAuthorities::<Runtime>::get().contains(&2)); + assert!(pallet_authority_members::Members::<Runtime>::get(2).is_some()); + + assert_noop!( + Identity::change_owner_key( + RuntimeOrigin::signed(bob.clone()), + ferdie.clone(), + signature.into() + ), + pallet_identity::Error::<gdev_runtime::Runtime>::OwnerKeyUsedAsValidator + ); + }) +} + /// test change owner key #[test] fn test_change_owner_key_validator_online() { -- GitLab