Skip to content

Conversation

@codebestia
Copy link

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

@binarybaron
Copy link

Did you run them?

@codebestia
Copy link
Author

Yes. 2 out of 3 passes
Screenshot 2025-12-25 at 05 48 03

The last test fails because of this error which has nothing to do with the testcase. This testcase on its own checks out. I reviewed other workflows and noticed the same issue.
Screenshot 2025-12-25 at 05 41 18

I believe this PR is ready.

@codebestia
Copy link
Author

Hello @binarybaron
Please could you review this PR and share your feedback? I’d like to move this forward and make sure it fully addresses the issue.

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 { .. })

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 { .. }

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.

let bob_swap_id = bob_swap.id;

let bob_swap = tokio::spawn(bob::run_until(bob_swap, |s| {
matches!(s, BobState::WaitingForCancelTimelockExpiration { .. })

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.

let bob_state = bob_swap.await??;
assert!(matches!(
bob_state,
BobState::WaitingForCancelTimelockExpiration { .. }

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.

}

#[tokio::test]
async fn given_correct_xmr_amount_bob_redeems_btc() {
Copy link

@binarybaron binarybaron Dec 28, 2025

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 }
}

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

Copy link

@binarybaron binarybaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

@binarybaron
Copy link

The new test also needs to be added to .github/workflows/ci.yml.

@codebestia
Copy link
Author

Screenshot 2025-12-29 at 01 39 39

Reviews Implemented and the tests passes.

@codebestia
Copy link
Author

Hello @binarybaron
This PR should be good to go; please let me know if I’m missing anything.

@codebestia
Copy link
Author

@binarybaron Could you take a look at this PR?

@binarybaron
Copy link

Please stop tagging me. I will review it once we find time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0.5 XMR] Integration test where Alice locks wrong amount

2 participants