mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Allow "anonymous" proxied accounts (#6236)
* Anonymous proxiers * More testing * More testing * Build fix * Build fix * Benchmarks. * fix benchmarking * add weights * fix line width Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -27,8 +27,8 @@ use crate::Module as Proxy;
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
fn add_proxies<T: Trait>(n: u32) -> Result<(), &'static str> {
|
||||
let caller: T::AccountId = account("caller", 0, SEED);
|
||||
fn add_proxies<T: Trait>(n: u32, maybe_who: Option<T::AccountId>) -> Result<(), &'static str> {
|
||||
let caller = maybe_who.unwrap_or_else(|| account("caller", 0, SEED));
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
for i in 0..n {
|
||||
Proxy::<T>::add_proxy(
|
||||
@@ -42,7 +42,7 @@ fn add_proxies<T: Trait>(n: u32) -> Result<(), &'static str> {
|
||||
|
||||
benchmarks! {
|
||||
_ {
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p)?;
|
||||
let p in 1 .. (T::MaxProxies::get() - 1).into() => add_proxies::<T>(p, None)?;
|
||||
}
|
||||
|
||||
proxy {
|
||||
@@ -68,6 +68,24 @@ benchmarks! {
|
||||
let p in ...;
|
||||
let caller: T::AccountId = account("caller", 0, SEED);
|
||||
}: _(RawOrigin::Signed(caller))
|
||||
|
||||
anonymous {
|
||||
let p in ...;
|
||||
}: _(RawOrigin::Signed(account("caller", 0, SEED)), T::ProxyType::default(), 0)
|
||||
|
||||
kill_anonymous {
|
||||
let p in 0 .. (T::MaxProxies::get() - 2).into();
|
||||
|
||||
let caller: T::AccountId = account("caller", 0, SEED);
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
Module::<T>::anonymous(RawOrigin::Signed(account("caller", 0, SEED)).into(), T::ProxyType::default(), 0)?;
|
||||
let height = system::Module::<T>::block_number();
|
||||
let ext_index = system::Module::<T>::extrinsic_index().unwrap_or(0);
|
||||
let anon = Module::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None);
|
||||
|
||||
add_proxies::<T>(p, Some(anon.clone()))?;
|
||||
|
||||
}: _(RawOrigin::Signed(anon), caller, T::ProxyType::default(), 0, height, ext_index)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -83,6 +101,8 @@ mod tests {
|
||||
assert_ok!(test_benchmark_add_proxy::<Test>());
|
||||
assert_ok!(test_benchmark_remove_proxy::<Test>());
|
||||
assert_ok!(test_benchmark_remove_proxies::<Test>());
|
||||
assert_ok!(test_benchmark_anonymous::<Test>());
|
||||
assert_ok!(test_benchmark_kill_anonymous::<Test>());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user