-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathpool_join_with_exact_asset_amount.rs
50 lines (46 loc) · 1.83 KB
/
pool_join_with_exact_asset_amount.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2024 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
//
// This file is part of Zeitgeist.
//
// Zeitgeist is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// Zeitgeist is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>.
#![no_main]
mod utils;
use libfuzzer_sys::fuzz_target;
use orml_traits::currency::MultiCurrency;
use utils::{construct_asset, ExactAssetAmountData};
use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps};
fuzz_target!(|data: ExactAssetAmountData| {
let mut ext = ExtBuilder::default().build();
ext.execute_with(|| {
// ensure that the account origin has a sufficient balance
for a in &data.pool_creation.assets {
let _ = Currencies::deposit(
construct_asset(*a),
&data.pool_creation.origin,
// In order to successfully join the pool, data.asset_amount more tokens needed
data.pool_creation.amount.saturating_add(data.asset_amount),
);
}
let pool_id = data.pool_creation.create_pool();
let _ = Swaps::pool_join_with_exact_asset_amount(
RuntimeOrigin::signed(data.origin),
pool_id,
construct_asset(data.asset),
data.asset_amount,
data.pool_amount,
);
});
let _ = ext.commit_all();
});