Skip to content

test(integration): add concurrent credential and reward claim integration test - #655

Closed
lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/issue-640-concurrent-credential-reward-claim
Closed

lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:test/issue-640-concurrent-credential-reward-claim

Conversation

@lmduy2612

Copy link
Copy Markdown

Description

Fixes #640

This PR adds cross-contract integration test coverage in tests/integration/full_flow.rs verifying that token reward claiming and credential NFT minting operate reliably in the same transaction session without interference:

  1. test_claim_reward_then_mint_credential_sequence:

    • Executes reward claims (quiz_midterm + quiz_final) first, bringing token balance and total_supply to 16,000.
    • Subsequently mints credential NFT for the learner.
    • Verifies credential validity, non-revocation status, and strictly consistent token balance and total supply.
  2. test_mint_credential_then_claim_reward_reverse_sequence:

    • Executes mint_credential first while token balance and supply are 0.
    • Subsequently claims token rewards for the completed quizzes.
    • Verifies that token rewards are properly credited (16,000) and that the previously minted credential remains intact.
  3. test_concurrent_multi_learner_claim_and_mint_same_session:

    • Executes interleaved reward claiming and credential minting across multiple learners (learner1 and learner2) in the same environment session without state reset.
    • Verifies isolation between learners, correct cumulative supply (32,000), and unique credential issuance without race conditions.

Verification

  • Run full suite: cargo test --test full_flow (All 4 tests passed)
  • Code formatted with rustfmt.

@DeFiVC DeFiVC closed this Oct 19, 2026
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 concurrent credential and reward claim integration test

2 participants