Task 3-1: Integration Test - Rental Lifecycle
Phase: 3 - Testing Priority: Medium Depends on: task-1-1, task-1-2 Reference: docs/BountyHunter-Backend/details/feature-nft-management/SPEC.md
Background
Test toàn bộ rental lifecycle: create → verify → confirm → finish/cancel/return.
Test scenarios
Happy path: Create → Verify → Confirm → Expire
- [ ]
POST /api/nft-rentalvớibountyBallId(productstatus=AVAILABLE) → orderstatus=NEW, productstatus=RENTING - [ ]
PUT /verify-order-creation/{id}với validtransactionHash→status=NEW_VERIFIED - [ ]
PUT /confirm-rent/{id}(as renter) → renter B-Coin deducted, owner credited,status=RENTING - Verify: renter balance giảm đúng
rentalFee - Verify: owner balance tăng đúng
rentalFee - adminFee - [ ] Simulate expiry →
NftRentalExpirationCheckBatchchạy →status=FINISHED, productstatus=AVAILABLE
Cancel flow
- [ ]
PUT /cancel-rental-order/{id}khistatus=NEW→status=CANCELLED, productstatus=AVAILABLE - [ ]
PUT /cancel-rental-order/{id}khistatus=RENTING→ error (không cho phép cancel khi đang renting) - [ ] Verify: B-Coin không bị deduct khi cancel từ
status=NEW
Return early
- [ ]
PUT /return-rental-early/{id}khi đangRENTING→status=RETURN_EARLY - [ ] Verify pro-rated refund: renter nhận lại portion coin chưa dùng
- [ ] Verify owner nhận coin cho thời gian đã dùng
- [ ] Notification gửi tới owner: "NFT returned early"
Concurrent confirm (liên quan task-1-2)
- [ ] 2 renters gọi
confirm-rent/{id}đồng thời → chỉ 1 thành công, 1 nhậnRENTAL_ORDER_NOT_AVAILABLE - [ ] Kiểm tra: không có double charge (verify balance chỉ bị deduct 1 lần)
Market listing
- [ ]
GET /market-rental(as owner) → không hiển thị listings của chính owner - [ ]
GET /market-rental(as other user) → hiển thị listing của owner
Minted NFT path
- [ ] Confirm rent với minted Bounty Ball →
NodeServerService.confirmSolanaNftRental()được gọi - [ ] Confirm rent với unminted Bounty Ball → chỉ DB update, không call NodeServer
Verification / Acceptance Criteria
- [ ] Happy path: tất cả status transitions đúng (
NEW→NEW_VERIFIED→RENTING→FINISHED) - [ ] B-Coin balance: deduct và credit đúng amount (bao gồm admin fee)
- [ ] Cancel: chỉ cho phép từ
NEW, không từRENTING - [ ] Market listing: owner không thấy listing của chính mình
- [ ] Minted vs unminted:
NodeServerServiceđược gọi đúng theo điều kiện - [ ] Test endpoints
finish-rental-ordervàtest-change-ownertrả 404 khi chạy với profilemain(liên quan task-1-1)
Files to Modify
- Test files trong
webmarketplace/src/test/hoặc integration test module