Skip to content

Task 4-3: Integration Test - MINT_ALLOCATION

Phase: 4 - Testing Priority: Medium Depends on: task-1-1, task-1-2 Reference: docs/BountyHunter-Backend/details/feature-prize-allocation/SPEC.md

Background

Test MINT_ALLOCATION action cho cả 3 NFT types: Hunter, Gauntlet, BountyBall.

Test scenarios

MINT_ALLOCATION - Hunter

  • [ ] Send action=MINT_ALLOCATION, mintAllocation={nftType=HUNTER, count=3} với valid userIdroomId
  • [ ] Verify: 3 NftHunterAllocation records tạo mới trong DB
  • [ ] Verify: records liên kết đúng với userIdroomId
  • [ ] Verify: createdAt timestamp hợp lý

MINT_ALLOCATION - Gauntlet

  • [ ] Send action=MINT_ALLOCATION, mintAllocation={nftType=GAUNTLET, count=2}
  • [ ] Verify: đúng 2 NftGauntletAllocation records tạo mới (không phải Hunter hay BountyBall)

MINT_ALLOCATION - BountyBall

  • [ ] Send action=MINT_ALLOCATION, mintAllocation={nftType=BOUNTY_BALL, count=5}
  • [ ] Verify: đúng 5 NftBountyBallAllocation records tạo mới

MINT_ALLOCATION idempotency

  • [ ] Send cùng MINT_ALLOCATION message 2 lần (cùng correlationId)
  • [ ] Verify: records chỉ tạo 1 lần (count không doubled)
  • [ ] Verify log: [IDEMPOTENCY] Duplicate message lần 2

Invalid nftType

  • [ ] Send với nftType=UNKNOWN_TYPE (không hợp lệ)
  • [ ] Verify: error logged, không tạo records, không crash listener
  • [ ] Verify: message được ACK (không requeue indefinitely)

Verification / Acceptance Criteria

  • [ ] Hunter/Gauntlet/BountyBall: đúng số lượng records, đúng type, đúng userId/roomId
  • [ ] Idempotent: second send với cùng correlationId → no additional records
  • [ ] Invalid nftType: graceful error handling, listener vẫn sống
  • [ ] DB records có đủ audit fields (userId, roomId, createdAt)

Files to Modify

  • Test files trong batch/src/test/ hoặc integration test module