From 5480a444442f2f35558ab6d08340954c1fd4475e Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 31 Oct 2024 12:40:51 +0100 Subject: [PATCH] additional integratio test --- integration-tests/src/ice/omni.rs | 78 ++++++++++++++++++++++++++++--- pallets/ice/src/lib.rs | 2 - 2 files changed, 71 insertions(+), 9 deletions(-) diff --git a/integration-tests/src/ice/omni.rs b/integration-tests/src/ice/omni.rs index 99161e76a..4a75ddb66 100644 --- a/integration-tests/src/ice/omni.rs +++ b/integration-tests/src/ice/omni.rs @@ -83,15 +83,9 @@ fn solver_should_find_solution_with_one_intent() { } #[test] -fn execute_solution_should_work_with_solved_intents() { +fn execute_solution_should_work_with_one_intent() { hydra_live_ext(PATH_TO_SNAPSHOT).execute_with(|| { hydradx_runtime::Balances::set_balance(&BOB.into(), 200_000_000_000_000); - assert_ok!(hydradx_runtime::Omnipool::set_asset_tradable_state( - hydradx_runtime::RuntimeOrigin::root(), - LRNA, - Tradability::SELL | Tradability::BUY - )); - let deadline: Moment = Timestamp::now() + 43_200_000; let intent_ids = submit_intents(vec![Intent { who: BOB.into(), @@ -126,3 +120,73 @@ fn execute_solution_should_work_with_solved_intents() { )); }); } + +#[test] +fn execute_solution_should_work_with_two_intents() { + hydra_live_ext(PATH_TO_SNAPSHOT).execute_with(|| { + hydradx_runtime::Balances::set_balance(&BOB.into(), 200_000_000_000_000); + assert_ok!(Currencies::update_balance( + hydradx_runtime::RuntimeOrigin::root(), + ALICE.into(), + 27, + 2_149_711_278_057, + )); + + let deadline: Moment = Timestamp::now() + 43_200_000; + let intent_ids = submit_intents(vec![ + Intent { + who: BOB.into(), + swap: Swap { + asset_in: 0, + asset_out: 27, + amount_in: 100_000_000_000_000, + amount_out: 1_149_711_278_057, + swap_type: pallet_ice::types::SwapType::ExactIn, + }, + deadline, + partial: true, + on_success: None, + on_failure: None, + }, + Intent { + who: ALICE.into(), + swap: Swap { + asset_in: 27, + asset_out: 0, + amount_in: 1_149_711_278_057, + amount_out: 100_000_000_000_000, + swap_type: pallet_ice::types::SwapType::ExactIn, + }, + deadline, + partial: true, + on_success: None, + on_failure: None, + }, + ]); + + let intents = vec![ + ( + intent_ids[0], + pallet_ice::Pallet::::get_intent(intent_ids[0]).unwrap(), + ), + ( + intent_ids[1], + pallet_ice::Pallet::::get_intent(intent_ids[1]).unwrap(), + ), + ]; + let resolved = solve_intents_with::(intents).unwrap(); + + dbg!(&resolved); + + let (trades, score) = + pallet_ice::Pallet::::calculate_trades_and_score(&resolved.to_vec()).unwrap(); + + assert_ok!(ICE::submit_solution( + RuntimeOrigin::signed(BOB.into()), + resolved, + BoundedTrades::try_from(trades).unwrap(), + score, + System::current_block_number() + )); + }); +} diff --git a/pallets/ice/src/lib.rs b/pallets/ice/src/lib.rs index e9b1efeee..7767d0d77 100644 --- a/pallets/ice/src/lib.rs +++ b/pallets/ice/src/lib.rs @@ -515,8 +515,6 @@ impl Pallet { .or_insert(resolved_intent.amount_out); } - let mut lrna_aquired = 0u128; - let mut matched_amounts = Vec::new(); let mut trades_instructions = Vec::new();