Skip to content

Commit

Permalink
additional integratio test
Browse files Browse the repository at this point in the history
  • Loading branch information
enthusiastmartin committed Oct 31, 2024
1 parent bbfaf8b commit 5480a44
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 9 deletions.
78 changes: 71 additions & 7 deletions integration-tests/src/ice/omni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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::<hydradx_runtime::Runtime>::get_intent(intent_ids[0]).unwrap(),
),
(
intent_ids[1],
pallet_ice::Pallet::<hydradx_runtime::Runtime>::get_intent(intent_ids[1]).unwrap(),
),
];
let resolved = solve_intents_with::<OmniSolverWithOmnipool>(intents).unwrap();

dbg!(&resolved);

let (trades, score) =
pallet_ice::Pallet::<hydradx_runtime::Runtime>::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()
));
});
}
2 changes: 0 additions & 2 deletions pallets/ice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,6 @@ impl<T: Config> Pallet<T> {
.or_insert(resolved_intent.amount_out);
}

let mut lrna_aquired = 0u128;

let mut matched_amounts = Vec::new();
let mut trades_instructions = Vec::new();

Expand Down

0 comments on commit 5480a44

Please sign in to comment.