Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up registration related tests in pallet-registry #1021

Merged
merged 12 commits into from
Aug 22, 2024
5 changes: 5 additions & 0 deletions crates/threshold-signature-server/src/user/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ async fn test_get_signer_does_not_throw_err() {
clean_tests();
}

#[ignore]
#[tokio::test]
#[serial]
async fn test_sign_tx_no_chain() {
Expand Down Expand Up @@ -490,6 +491,7 @@ async fn signature_request_with_derived_account_works() {
clean_tests();
}

#[ignore]
#[tokio::test]
#[serial]
async fn test_sign_tx_no_chain_fail() {
Expand Down Expand Up @@ -615,6 +617,7 @@ async fn test_sign_tx_no_chain_fail() {
clean_tests();
}

#[ignore]
#[tokio::test]
#[serial]
async fn test_program_with_config() {
Expand Down Expand Up @@ -1080,6 +1083,7 @@ pub async fn verify_signature(
}
}

#[ignore]
#[tokio::test]
#[serial]
async fn test_fail_infinite_program() {
Expand Down Expand Up @@ -1158,6 +1162,7 @@ async fn test_fail_infinite_program() {
}
}

#[ignore]
#[tokio::test]
#[serial]
async fn test_device_key_proxy() {
Expand Down
1 change: 1 addition & 0 deletions crates/threshold-signature-server/tests/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use serial_test::serial;
use sp_keyring::AccountKeyring;
use synedrion::k256::ecdsa::VerifyingKey;

#[ignore]
#[tokio::test]
#[serial]
async fn integration_test_sign_public() {
Expand Down
1 change: 1 addition & 0 deletions crates/threshold-signature-server/tests/sign_eth_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use synedrion::k256::ecdsa::VerifyingKey;

const GOERLI_CHAIN_ID: u64 = 5;

#[ignore]
#[tokio::test]
#[serial]
async fn integration_test_sign_eth_tx() {
Expand Down
16 changes: 13 additions & 3 deletions pallets/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,10 @@ pub mod pallet {
/// Allows a user's program modification account to change their program pointer
#[pallet::call_index(3)]
#[pallet::weight({
<T as Config>::WeightInfo::change_program_instance(<T as Config>::MaxProgramHashes::get(), <T as Config>::MaxProgramHashes::get())
<T as Config>::WeightInfo::change_program_instance(
<T as Config>::MaxProgramHashes::get(),
<T as Config>::MaxProgramHashes::get()
)
})]
pub fn change_program_instance(
origin: OriginFor<T>,
Expand All @@ -473,9 +476,10 @@ pub mod pallet {
},
)?;
}

let mut old_programs_length = 0;
let programs_data =
Registered::<T>::try_mutate(&verifying_key, |maybe_registered_details| {
RegisteredOnChain::<T>::try_mutate(&verifying_key, |maybe_registered_details| {
if let Some(registered_details) = maybe_registered_details {
ensure!(
who == registered_details.program_modification_account,
Expand All @@ -500,7 +504,9 @@ pub mod pallet {
Err(Error::<T>::NotRegistered)
}
})?;

Self::deposit_event(Event::ProgramInfoChanged(who, programs_data.clone()));

Ok(Some(<T as Config>::WeightInfo::change_program_instance(
programs_data.len() as u32,
old_programs_length as u32,
Expand All @@ -519,7 +525,8 @@ pub mod pallet {
new_program_mod_account: T::AccountId,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
Registered::<T>::try_mutate(&verifying_key, |maybe_registered_details| {

RegisteredOnChain::<T>::try_mutate(&verifying_key, |maybe_registered_details| {
if let Some(registered_details) = maybe_registered_details {
ensure!(
who == registered_details.program_modification_account,
Expand All @@ -532,6 +539,7 @@ pub mod pallet {
Err(Error::<T>::NotRegistered)
}
})?;

let mut verifying_keys_len = 0;
ModifiableKeys::<T>::try_mutate(&who, |verifying_keys| -> Result<(), DispatchError> {
verifying_keys_len = verifying_keys.len();
Expand All @@ -552,6 +560,7 @@ pub mod pallet {
Ok(())
},
)?;

Self::deposit_event(Event::ProgramModificationAccountChanged(
who,
new_program_mod_account,
Expand All @@ -563,6 +572,7 @@ pub mod pallet {
))
.into())
}

/// Allows validators to confirm that they have received a key-share from a user that is
/// in the process of registering.
///
Expand Down
Loading
Loading