Skip to content

Commit 1686f25

Browse files
Add swap_both_fails_bridge_native_overflow test
1 parent 7510fd6 commit 1686f25

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

crates/pallet-evm-swap/src/tests/native_to_evm.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,31 @@ fn swap_both_fails_bridge_evm_no_funds() {
265265
);
266266
});
267267
}
268+
269+
/// This test verifies that both calls fail in case bridge native balance results into overflow.
270+
#[test]
271+
fn swap_both_fails_bridge_native_overflow() {
272+
new_test_ext().execute_with_ext(|_| {
273+
Balances::write_balance(&BridgePotNative::get(), Balance::MAX).unwrap();
274+
275+
// Invoke the `swap` under test.
276+
assert_noop!(
277+
EvmSwap::swap(
278+
RuntimeOrigin::signed(source_swap_native_account()),
279+
target_swap_evm_account(),
280+
100,
281+
),
282+
DispatchError::Arithmetic(ArithmeticError::Overflow)
283+
);
284+
285+
// Invoke the `swap_keep_alive` under test.
286+
assert_noop!(
287+
EvmSwap::swap_keep_alive(
288+
RuntimeOrigin::signed(source_swap_native_account()),
289+
target_swap_evm_account(),
290+
100,
291+
),
292+
DispatchError::Arithmetic(ArithmeticError::Overflow)
293+
);
294+
});
295+
}

0 commit comments

Comments
 (0)