Skip to content

Commit

Permalink
fix: benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshvarma committed Sep 26, 2023
1 parent aa587d0 commit 2609aec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 2 additions & 4 deletions pallets/unified-accounts/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}

#[benchmarks(
where <<T as Config>::SignatureHelper as SignatureHelper>::Signature: IsType<[u8;65]>
)]
#[benchmarks]
mod benchmarks {
use super::*;

Expand All @@ -39,7 +37,7 @@ mod benchmarks {
let eth_secret_key = libsecp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap();
let evm_address = Pallet::<T>::eth_address(&eth_secret_key);
let signature = Pallet::<T>::eth_sign_prehash(
&T::SignatureHelper::build_signing_payload(&caller),
&Pallet::<T>::build_signing_payload(&caller),
&eth_secret_key,
)
.into();
Expand Down
8 changes: 6 additions & 2 deletions pallets/unified-accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@
//! * `claim_default_evm_address`: Creates the double mapping with default evm address given that
//! no prior mapping exists.
//!
//! WARNINGS:
//! * This pallet only handles transfer of native balance only, for the rest of native assets
//! hold by evm address like XC20, DAppStaking unclaimed rewards, etc should be transferred
//! manually beforehand by user himself otherwise FUNDS WILL BE LOST FOREVER.
//! * Once mapping is created it cannot be changed.
//!
//! ## Traits
//!
//! * `UnifiedAddressMapper`: Interface to access pallet's mappings with defaults
//! * `SignatureHelper`: Signature verification scheme for proving address ownership
//!
//! ## Implementations
//!
Expand All @@ -53,7 +58,6 @@
//! for account id mappings to h160.
//! * `KillAccountMapping`: [`OnKilledAccount`](frame_support::traits::OnKilledAccount) implementation to remove
//! the mappings from storage after account is reaped.
//! * `EIP712Signature`: EIP712 signature implementation for [`SignatureHelper`](crate::SignatureHelper)

#![cfg_attr(not(feature = "std"), no_std)]

Expand Down
10 changes: 10 additions & 0 deletions pallets/unified-accounts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ fn account_default_claim_should_not_work_if_collision() {
UnifiedAccounts::claim_default_evm_address(RuntimeOrigin::signed(BOB)),
Error::<TestRuntime>::AlreadyMapped
);

// check mappings are consistent
assert_eq!(
<UnifiedAccounts as UnifiedAddressMapper<_>>::to_h160(&ALICE),
Some(bob_default_h160)
);
assert_eq!(
<UnifiedAccounts as UnifiedAddressMapper<_>>::to_account_id(&bob_default_h160),
Some(ALICE)
);
});
}

Expand Down

0 comments on commit 2609aec

Please sign in to comment.