diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 911d2be7e54d1a0d68a24119dd30e52cdb04f5c7..9ee556b3274e9aa46b219d412ae94da4fe1efe24 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() {