diff --git a/Cargo.lock b/Cargo.lock index b9f86f6ac3..9e49db4cc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6273,7 +6273,7 @@ dependencies = [ [[package]] name = "pallet-author-mapping" -version = "2.0.4" +version = "2.0.5" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/author-mapping/Cargo.toml b/pallets/author-mapping/Cargo.toml index 234e91cff1..e804d719cc 100644 --- a/pallets/author-mapping/Cargo.toml +++ b/pallets/author-mapping/Cargo.toml @@ -3,7 +3,7 @@ name = "pallet-author-mapping" authors = [ "PureStake" ] description = "Maps AuthorIds to AccountIds Useful for associating consensus authors with in-runtime accounts" edition = "2018" -version = "2.0.4" +version = "2.0.5" [dependencies] log = { version = "0.4", default-features = false } diff --git a/pallets/author-mapping/src/lib.rs b/pallets/author-mapping/src/lib.rs index a55022bc55..50fd884475 100644 --- a/pallets/author-mapping/src/lib.rs +++ b/pallets/author-mapping/src/lib.rs @@ -144,8 +144,8 @@ pub mod pallet { Error::::NotYourAssociation ); - MappingWithDeposit::::insert(&new_author_id, &stored_info); MappingWithDeposit::::remove(&old_author_id); + MappingWithDeposit::::insert(&new_author_id, &stored_info); >::deposit_event(Event::AuthorRotated(new_author_id, stored_info.account)); diff --git a/pallets/author-mapping/src/tests.rs b/pallets/author-mapping/src/tests.rs index c5d82d54c7..0e960f84ce 100644 --- a/pallets/author-mapping/src/tests.rs +++ b/pallets/author-mapping/src/tests.rs @@ -255,8 +255,21 @@ fn registered_author_cannot_be_rotated_by_non_owner() { }) } -//TODO Test ideas in case we bring back the narc extrinsic -// unstaked account can be narced after period -// unstaked account cannot be narced before period -// staked account can be narced after period -// staked account cannot be narced before period +#[test] +fn rotating_to_the_same_author_id_leaves_registration_in_tact() { + ExtBuilder::default() + .with_balances(vec![(1, 1000)]) + .with_mappings(vec![(TestAuthor::Alice.into(), 1)]) + .build() + .execute_with(|| { + assert_ok!(AuthorMapping::update_association( + Origin::signed(1), + TestAuthor::Alice.into(), + TestAuthor::Alice.into() + )); + assert_eq!( + AuthorMapping::account_id_of(&TestAuthor::Alice.into()), + Some(1) + ); + }) +}