Skip to content

Commit

Permalink
Verify that minimum/maximum weights are respected
Browse files Browse the repository at this point in the history
  • Loading branch information
maltekliemann committed Mar 28, 2022
1 parent 6c8d221 commit b386e84
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions zrml/swaps/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,48 @@ fn join_pool_exit_pool_does_not_create_extra_tokens() {
});
}

#[test]
fn create_pool_fails_on_weight_below_minimum_weight() {
ExtBuilder::default().build().execute_with(|| {
ASSETS.iter().cloned().for_each(|asset| {
let _ = Currencies::deposit(asset, &BOB, _100);
});
assert_noop!(
Swaps::create_pool(
BOB,
ASSETS.iter().cloned().collect(),
Some(ASSETS.last().unwrap().clone()),
0,
ScoringRule::CPMM,
Some(0),
Some(vec!(_2, <Runtime as crate::Config>::MinWeight::get() - 1, _2, _2))
),
crate::Error::<Runtime>::BelowMinimumWeight,
);
});
}

#[test]
fn create_pool_fails_on_weight_above_maximum_weight() {
ExtBuilder::default().build().execute_with(|| {
ASSETS.iter().cloned().for_each(|asset| {
let _ = Currencies::deposit(asset, &BOB, _100);
});
assert_noop!(
Swaps::create_pool(
BOB,
ASSETS.iter().cloned().collect(),
Some(ASSETS.last().unwrap().clone()),
0,
ScoringRule::CPMM,
Some(0),
Some(vec!(_2, <Runtime as crate::Config>::MaxWeight::get() + 1, _2, _2))
),
crate::Error::<Runtime>::AboveMaximumWeight,
);
});
}

fn alice_signed() -> Origin {
Origin::signed(ALICE)
}
Expand Down

0 comments on commit b386e84

Please sign in to comment.