Skip to content

Commit

Permalink
add router benchmark for buy including stableswap
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoka committed Jul 26, 2023
1 parent c03c2bf commit 884d9e4
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions runtime/hydradx/src/benchmarking/route_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,21 @@ runtime_benchmarks! {
}

buy {
let n in 1..2;

initialize_omnipool()?;
let n in 1..3;
set_period::<Runtime>(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::<Runtime>("caller", 0, 100 * UNITS, HDX);
let init_asset_in_balance = 100 * UNITS;
let caller: AccountId = create_funded_account::<Runtime>("caller", 0, init_asset_in_balance, DAI);

let amount_to_buy = 10 * UNITS;
}: {
RouteExecutor::<Runtime>::buy(RawOrigin::Signed(caller.clone()).into(), asset_in, asset_out, amount_to_buy, u128::MAX, trades)?
}
verify{
assert!(<Currencies as MultiCurrency<_>>::total_balance(asset_out, &caller) < 100 * UNITS);
assert!(<Currencies as MultiCurrency<_>>::total_balance(asset_out, &caller) > 0);
assert!(<Currencies as MultiCurrency<_>>::total_balance(asset_in, &caller) < 100 * UNITS);
assert_eq!(<Currencies as MultiCurrency<_>>::total_balance(asset_out, &caller), amount_to_buy);
}

}
Expand Down

0 comments on commit 884d9e4

Please sign in to comment.