-
Notifications
You must be signed in to change notification settings - Fork 40
test: Integration tests for Bob and Alice swaps #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
test: Integration tests for Bob and Alice swaps #845
Conversation
|
Did you run them? |
|
Hello @binarybaron |
swap/tests/bob_xmr_validation.rs
Outdated
| let (bob_swap, bob_join_handle) = ctx.bob_swap().await; | ||
| let bob_swap_id = bob_swap.id; | ||
| let bob_swap = tokio::spawn(bob::run_until(bob_swap, |s| { | ||
| matches!(s, BobState::WaitingForCancelTimelockExpiration { .. }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to ensure that Bob goes into XmrLockTransactionCandidate and then into WaitingForCancelTimelockExpiration.
| let bob_state = bob_swap.await??; | ||
| assert!(matches!( | ||
| bob_state, | ||
| BobState::WaitingForCancelTimelockExpiration { .. } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: We need to ensure that Bob goes into XmrLockTransactionCandidate and then into WaitingForCancelTimelockExpiration.
swap/tests/bob_xmr_validation.rs
Outdated
| let bob_swap_id = bob_swap.id; | ||
|
|
||
| let bob_swap = tokio::spawn(bob::run_until(bob_swap, |s| { | ||
| matches!(s, BobState::WaitingForCancelTimelockExpiration { .. }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: We need to ensure that Bob goes into XmrLockTransactionCandidate and then into WaitingForCancelTimelockExpiration.
swap/tests/bob_xmr_validation.rs
Outdated
| let bob_state = bob_swap.await??; | ||
| assert!(matches!( | ||
| bob_state, | ||
| BobState::WaitingForCancelTimelockExpiration { .. } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: We need to ensure that Bob goes into XmrLockTransactionCandidate and then into WaitingForCancelTimelockExpiration.
swap/tests/bob_xmr_validation.rs
Outdated
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn given_correct_xmr_amount_bob_redeems_btc() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed as this is already tested in swap/tests/happy_path.rs.
| state3.xmr = state3.xmr.checked_sub(one_piconero).unwrap(); | ||
|
|
||
| Self::BtcLocked { state3 } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an empty line below
binarybaron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments
|
The new test also needs to be added to |
|
Hello @binarybaron |
|
@binarybaron Could you take a look at this PR? |
|
Please stop tagging me. I will review it once we find time. |



Overview
Adds integration tests to validate Bob's Monero (XMR) amount verification logic during atomic swaps. These tests ensure Bob correctly validates the XMR amount Alice locks before proceeding, protecting against incorrect or malicious amounts.
Related Issue
Closes #828