From 884d9e49d7433c98efaf8d115a69f3b83e325ab1 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 26 Jul 2023 17:24:18 +0200 Subject: [PATCH] add router benchmark for buy including stableswap --- .../src/benchmarking/route_executor.rs | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/runtime/hydradx/src/benchmarking/route_executor.rs b/runtime/hydradx/src/benchmarking/route_executor.rs index 2c5835705..ddc1c97fa 100644 --- a/runtime/hydradx/src/benchmarking/route_executor.rs +++ b/runtime/hydradx/src/benchmarking/route_executor.rs @@ -353,27 +353,21 @@ runtime_benchmarks! { } buy { - let n in 1..2; - - initialize_omnipool()?; + let n in 1..3; + set_period::(11); - let asset_in = HDX; - let asset_out = DAI; - let trades = vec![Trade { - pool: PoolType::Omnipool, - asset_in: HDX, - asset_out: DAI - }]; + let (asset_in,asset_out,trades) = generate_trades_with_pools(n)?; - let caller: AccountId = create_funded_account::("caller", 0, 100 * UNITS, HDX); + let init_asset_in_balance = 100 * UNITS; + let caller: AccountId = create_funded_account::("caller", 0, init_asset_in_balance, DAI); let amount_to_buy = 10 * UNITS; }: { RouteExecutor::::buy(RawOrigin::Signed(caller.clone()).into(), asset_in, asset_out, amount_to_buy, u128::MAX, trades)? } verify{ - assert!(>::total_balance(asset_out, &caller) < 100 * UNITS); - assert!(>::total_balance(asset_out, &caller) > 0); + assert!(>::total_balance(asset_in, &caller) < 100 * UNITS); + assert_eq!(>::total_balance(asset_out, &caller), amount_to_buy); } }