From 256281afe6952208114f4b544166b82b2c54fa24 Mon Sep 17 00:00:00 2001 From: maltekliemann Date: Mon, 28 Mar 2022 19:06:32 +0200 Subject: [PATCH] Check that total weight does not exceed maximum --- zrml/swaps/src/tests.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/zrml/swaps/src/tests.rs b/zrml/swaps/src/tests.rs index ad767a290..37788b790 100644 --- a/zrml/swaps/src/tests.rs +++ b/zrml/swaps/src/tests.rs @@ -1189,6 +1189,28 @@ fn create_pool_fails_on_weight_above_maximum_weight() { }); } +#[test] +fn create_pool_fails_on_total_weight_above_maximum_total_weight() { + ExtBuilder::default().build().execute_with(|| { + ASSETS.iter().cloned().for_each(|asset| { + let _ = Currencies::deposit(asset, &BOB, _100); + }); + let weight = ::MaxTotalWeight::get() / 4 + 100; + assert_noop!( + Swaps::create_pool( + BOB, + ASSETS.iter().cloned().collect(), + Some(ASSETS.last().unwrap().clone()), + 0, + ScoringRule::CPMM, + Some(0), + Some(vec![weight; 4]), + ), + crate::Error::::MaxTotalWeight, + ); + }); +} + fn alice_signed() -> Origin { Origin::signed(ALICE) }