Skip to content

test(bidding): add cancel-vs-accept interleaving regression#1380

Merged
Baskarayelu merged 7 commits into
QuickLendX:mainfrom
Kuhai9801:fix/qlx-1302-bid-cancel-accept-tests
Jun 19, 2026
Merged

test(bidding): add cancel-vs-accept interleaving regression#1380
Baskarayelu merged 7 commits into
QuickLendX:mainfrom
Kuhai9801:fix/qlx-1302-bid-cancel-accept-tests

Conversation

@Kuhai9801

Copy link
Copy Markdown
Contributor

📝 Description

Adds focused Soroban regression coverage for cancel_bid versus accept_bid_and_fund on the same bid.

🔧 Changes Made

  • Adds quicklendx-contracts/src/test_bid_cancel_accept_race.rs.
  • Covers cancel-then-accept: the later accept fails with InvalidStatus, no escrow/investment/funding state is created, and the cancelled bid is not returned by get_best_bid.
  • Covers accept-then-cancel: the later cancel returns false, while bid, invoice, escrow, investment, indexes, and token balances stay consistent.

🧪 Testing

  • rustfmt --check --edition 2021 quicklendx-contracts/src/test_bid_cancel_accept_race.rs
  • git diff --check
  • Not run locally: cargo test / cargo clippy

🔗 Related Issues

Closes #1302

🧪 How to Test

  1. cd quicklendx-contracts
  2. cargo test --features legacy-tests test_bid_cancel_accept_race -- --nocapture

@Kuhai9801

Copy link
Copy Markdown
Contributor Author

Ready for review.

One acceptance-note caveat: the issue asks for the losing operation to fail with QuickLendXError. The cancel-then-accept ordering does assert QuickLendXError::InvalidStatus. For the accept-then-cancel ordering, the existing public cancel_bid API returns bool, so this PR documents and asserts the current guard behavior: cancel_bid returns false once the bid is already Accepted, without mutating funded invoice, escrow, or investment state.

I kept this test-only rather than changing the public contract API.

CI is green on the latest push. The repository workflow runs cargo check, cargo test, WASM size checks, and coverage gates. It does not currently run cargo clippy; a whole-repo clippy run still hits pre-existing repo-wide lints outside this PR’s scoped changes.

@Kuhai9801 Kuhai9801 marked this pull request as ready for review June 19, 2026 08:17
@Baskarayelu

Copy link
Copy Markdown
Contributor

good interleaving regression - cancel racing accept on the same invoice is precisely the concurrency edge worth pinning. merging 👍

@Baskarayelu Baskarayelu merged commit e874ff7 into QuickLendX:main Jun 19, 2026
1 check passed
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.

Add concurrency interleaving tests for cancel_bid versus accept_bid_and_fund on the same invoice

2 participants