Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gj/ux-fixes' into gj/ux-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro committed Nov 10, 2023
2 parents 4fe65b5 + 53ad646 commit 673fc05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
37 changes: 13 additions & 24 deletions pallets/ocex/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

use super::*;
use crate::Pallet as Ocex;
use frame_benchmarking::v1::{account, benchmarks};
use frame_benchmarking::{
v1::{account, benchmarks},
whitelisted_caller,
};
use frame_support::{
traits::{EnsureOrigin, UnfilteredDispatchable},
BoundedVec,
Expand Down Expand Up @@ -68,20 +71,11 @@ fn tpc(base_asset: AssetId, quote_asset: AssetId) -> TradingPairConfig {

benchmarks! {
register_main_account {
let b in 0 .. 50_000;
let origin = T::EnclaveOrigin::try_successful_origin().unwrap();
let account = T::EnclaveOrigin::try_successful_origin().unwrap();
let main: T::AccountId = match unsafe { origin.clone().into().unwrap_unchecked() } {
RawOrigin::Signed(account) => account.into(),
_ => panic!("wrong RawOrigin returned")
};
let proxy: T::AccountId = match unsafe { account.into().unwrap_unchecked() } {
RawOrigin::Signed(account) => account.into(),
_ => panic!("wrong RawOrigin returned")
};
let b in 0 .. 255;
let main: T::AccountId = whitelisted_caller();
let proxy = T::AccountId::decode(&mut &[b as u8; 32].to_vec()[..]).unwrap();
<ExchangeState<T>>::put(true);
let call = Call::<T>::register_main_account { proxy: proxy.clone() };
}: { call.dispatch_bypass_filter(origin)? }
}: _(RawOrigin::Signed(main.clone()), proxy.clone())
verify {
assert_last_event::<T>(Event::MainAccountRegistered {
main,
Expand All @@ -91,18 +85,13 @@ benchmarks! {

add_proxy_account {
let x in 0 .. 255; // should not overflow u8
let origin = T::EnclaveOrigin::try_successful_origin().unwrap();
let main: T::AccountId = match unsafe { origin.clone().into().unwrap_unchecked() } {
RawOrigin::Signed(account) => account.into(),
_ => panic!("wrong RawOrigin returned")
};
let main: T::AccountId = whitelisted_caller();
let proxy = T::AccountId::decode(&mut &[x as u8; 32].to_vec()[..]).unwrap();
<ExchangeState<T>>::put(true);
Ocex::<T>::register_main_account(origin.clone(), main.clone())?;
let call = Call::<T>::add_proxy_account { proxy: proxy.clone() };
}: { call.dispatch_bypass_filter(origin)? }
Ocex::<T>::register_main_account(RawOrigin::Signed(main.clone()).into(), main.clone())?;
}: _(RawOrigin::Signed(main.clone()), proxy.clone())
verify {
assert_last_event::<T>(Event::MainAccountRegistered {
assert_last_event::<T>(Event::NewProxyAdded {
main,
proxy
}.into());
Expand Down Expand Up @@ -366,7 +355,7 @@ benchmarks! {
BalanceOf::<T>::decode(&mut &(u128::MAX).to_le_bytes()[..]).unwrap()
)?;
let call = Call::<T>::claim_withdraw { snapshot_id: x as u64, account: main.clone() };
}: { call.dispatch_bypass_filter(origin)? }
}: _(RawOrigin::Signed(main.clone()), x as u64, main.clone())
verify {
assert_last_event::<T>(Event::WithdrawalClaimed {
main,
Expand Down
2 changes: 1 addition & 1 deletion pallets/thea-executor/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ benchmarks! {
<Metadata<T>>::insert(100, metadata);
<T as pallet::Config>::Currency::mint_into(&account, 100_000_000_000_000u128.saturated_into()).unwrap();
<ApprovedDeposits<T>>::insert(account.clone(), deposits);
}: _(RawOrigin::None, 10,account.clone())
}: _(RawOrigin::Signed(account.clone()), 10,account.clone())
verify {
let current_balance = <T as pallet::Config>::Assets::balance(asset_id.into(), &account);
assert_eq!(current_balance, 1_000_000_000_000_000u128.saturated_into());
Expand Down

0 comments on commit 673fc05

Please sign in to comment.