Skip to content

Commit

Permalink
Run fmt after rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
MxmUrw committed Oct 1, 2024
1 parent 840a85c commit b687975
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
42 changes: 26 additions & 16 deletions state-chain/pallets/cf-swapping/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,21 @@ fn swaps_get_retried_after_failure() {
assert_event_sequence!(
Test,
RuntimeEvent::Swapping(Event::SwapExecuted { swap_id: SwapId(2), .. }),
RuntimeEvent::Swapping(Event::SwapEgressScheduled { swap_request_id: SwapRequestId(2), .. }),
RuntimeEvent::Swapping(Event::SwapRequestCompleted { swap_request_id: SwapRequestId(2) }),
RuntimeEvent::Swapping(Event::SwapEgressScheduled {
swap_request_id: SwapRequestId(2),
..
}),
RuntimeEvent::Swapping(Event::SwapRequestCompleted {
swap_request_id: SwapRequestId(2)
}),
RuntimeEvent::Swapping(Event::SwapExecuted { swap_id: SwapId(1), .. }),
RuntimeEvent::Swapping(Event::SwapEgressScheduled { swap_request_id: SwapRequestId(1), .. }),
RuntimeEvent::Swapping(Event::SwapRequestCompleted { swap_request_id: SwapRequestId(1) }),
RuntimeEvent::Swapping(Event::SwapEgressScheduled {
swap_request_id: SwapRequestId(1),
..
}),
RuntimeEvent::Swapping(Event::SwapRequestCompleted {
swap_request_id: SwapRequestId(1)
}),
);
});
}
Expand Down Expand Up @@ -1433,7 +1443,7 @@ mod swap_batching {

#[test]
fn single_swap() {
let swap1 = Swap::new(0, 0, Asset::Btc, Asset::Usdc, 1000, None, []);
let swap1 = Swap::new(0.into(), 0.into(), Asset::Btc, Asset::Usdc, 1000, None, []);
let mut swaps = vec![swap1.clone()];

let swap_states = vec![swap1.to_state(None)];
Expand All @@ -1451,9 +1461,9 @@ mod swap_batching {

#[test]
fn swaps_fail_into_stable() {
let swap1 = Swap::new(0, 0, Asset::Btc, Asset::Usdc, 500, None, []);
let swap2 = Swap::new(1, 1, Asset::Btc, Asset::Eth, 1000, None, []);
let swap3 = Swap::new(2, 2, Asset::Eth, Asset::Usdc, 1000, None, []);
let swap1 = Swap::new(0.into(), 0.into(), Asset::Btc, Asset::Usdc, 500, None, []);
let swap2 = Swap::new(1.into(), 1.into(), Asset::Btc, Asset::Eth, 1000, None, []);
let swap3 = Swap::new(2.into(), 2.into(), Asset::Eth, Asset::Usdc, 1000, None, []);

let mut swaps = vec![swap1.clone(), swap2.clone(), swap3.clone()];

Expand All @@ -1475,9 +1485,9 @@ mod swap_batching {
fn swaps_fail_from_stable() {
// BTC swap should be removed because it would result in a larger amount
// of USDC and thus will have higher impact on the Eth pool
let swap1 = Swap::new(1, 1, Asset::Btc, Asset::Eth, 1, None, []);
let swap2 = Swap::new(2, 2, Asset::Usdc, Asset::Eth, 1000, None, []);
let swap3 = Swap::new(3, 3, Asset::Eth, Asset::Usdc, 100, None, []);
let swap1 = Swap::new(1.into(), 1.into(), Asset::Btc, Asset::Eth, 1, None, []);
let swap2 = Swap::new(2.into(), 2.into(), Asset::Usdc, Asset::Eth, 1000, None, []);
let swap3 = Swap::new(3.into(), 3.into(), Asset::Eth, Asset::Usdc, 100, None, []);

let mut swaps = vec![swap1.clone(), swap2.clone(), swap3.clone()];

Expand Down Expand Up @@ -1534,11 +1544,11 @@ mod swap_batching {
assert_event_sequence!(
Test,
RuntimeEvent::Swapping(Event::BatchSwapFailed { .. }),
RuntimeEvent::Swapping(Event::SwapExecuted { swap_id: 2, .. }),
RuntimeEvent::Swapping(Event::SwapExecuted { swap_id: SwapId(2), .. }),
RuntimeEvent::Swapping(Event::SwapEgressScheduled { .. }),
RuntimeEvent::Swapping(Event::SwapRequestCompleted { .. }),
RuntimeEvent::Swapping(Event::SwapRescheduled {
swap_id: 1,
swap_id: SwapId(1),
execute_at: SWAP_RESCHEDULED_BLOCK
}),
);
Expand All @@ -1555,7 +1565,7 @@ mod swap_batching {
.then_execute_with(|_| {
assert_has_matching_event!(
Test,
RuntimeEvent::Swapping(Event::SwapExecuted { swap_id: 1, .. }),
RuntimeEvent::Swapping(Event::SwapExecuted { swap_id: SwapId(1), .. }),
);

assert_eq!(CollectedNetworkFee::<Test>::get(), 1500 + 2000);
Expand Down Expand Up @@ -1600,8 +1610,8 @@ mod swap_batching {
Test,
RuntimeEvent::Swapping(Event::BatchSwapFailed { .. }),
RuntimeEvent::Swapping(Event::BatchSwapFailed { .. }),
RuntimeEvent::Swapping(Event::SwapRescheduled { swap_id: 2, .. }),
RuntimeEvent::Swapping(Event::SwapRescheduled { swap_id: 1, .. }),
RuntimeEvent::Swapping(Event::SwapRescheduled { swap_id: SwapId(2), .. }),
RuntimeEvent::Swapping(Event::SwapRescheduled { swap_id: SwapId(1), .. }),
);

assert_eq!(CollectedNetworkFee::<Test>::get(), 0);
Expand Down
13 changes: 9 additions & 4 deletions state-chain/pallets/cf-swapping/src/tests/fill_or_kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ fn price_limit_is_respected_in_fok_swap() {
swap_request_id: SwapRequestId(1)
}),
RuntimeEvent::Swapping(Event::SwapExecuted { swap_id: FOK_SWAP_2_ID, .. }),
RuntimeEvent::Swapping(Event::SwapEgressScheduled { swap_request_id: SwapRequestId(3), .. }),
RuntimeEvent::Swapping(Event::SwapRequestCompleted { swap_request_id: SwapRequestId(3) }),
RuntimeEvent::Swapping(Event::SwapEgressScheduled {
swap_request_id: SwapRequestId(3),
..
}),
RuntimeEvent::Swapping(Event::SwapRequestCompleted {
swap_request_id: SwapRequestId(3)
}),
RuntimeEvent::Swapping(Event::SwapRescheduled {
swap_id: FOK_SWAP_1_ID,
execute_at: SWAP_RETRIED_AT_BLOCK
Expand Down Expand Up @@ -233,8 +238,8 @@ fn fok_swap_gets_refunded_due_to_price_limit() {

#[test]
fn storage_state_rolls_back_on_fok_violation() {
const FOK_SWAP_ID: u64 = 1;
const OTHER_SWAP_ID: u64 = 2;
const FOK_SWAP_ID: SwapId = SwapId(1);
const OTHER_SWAP_ID: SwapId = SwapId(2);

const SWAPS_SCHEDULED_FOR_BLOCK: u64 = INIT_BLOCK + SWAP_DELAY_BLOCKS as u64;

Expand Down

0 comments on commit b687975

Please sign in to comment.