Skip to content

Commit

Permalink
Add tests for InvalidAmountKeep
Browse files Browse the repository at this point in the history
  • Loading branch information
maltekliemann committed Oct 14, 2024
1 parent 70a891a commit be532f3
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion zrml/neo-swaps/src/tests/combo_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ fn combo_sell_fails_on_invalid_partition(
indices_sell: Vec<u16>,
) {
ExtBuilder::default().build().execute_with(|| {
println!("{:?}", _1_7);
let market_id = create_market_and_deploy_pool(
ALICE,
BASE_ASSET,
Expand Down Expand Up @@ -571,3 +570,41 @@ fn combo_sell_fails_on_large_amount() {
);
});
}

#[test_case(vec![], 1)]
#[test_case(vec![2], _2)]
fn combo_sell_fails_on_invalid_amount_keep(keep_indices: Vec<u16>, amount_in_keep: u128) {
ExtBuilder::default().build().execute_with(|| {
let spot_prices = vec![25 * CENT; 4];
let asset_count = spot_prices.len() as u16;
let swap_fee = CENT;
let market_id = create_market_and_deploy_pool(
ALICE,
BASE_ASSET,
MarketType::Categorical(asset_count),
_10,
spot_prices,
CENT,
);

let buy = vec![Asset::CategoricalOutcome(market_id, 0)];
let sell = vec![Asset::CategoricalOutcome(market_id, 1)];
let keep: Vec<_> =
keep_indices.iter().map(|&i| Asset::CategoricalOutcome(market_id, i)).collect();

assert_noop!(
NeoSwaps::combo_sell(
RuntimeOrigin::signed(BOB),
market_id,
asset_count,
buy.clone(),
keep.clone(),
sell.clone(),
_1,
amount_in_keep,
0,
),
Error::<Runtime>::InvalidAmountKeep
);
});
}

0 comments on commit be532f3

Please sign in to comment.