Skip to content

test: add unit tests for useRewardDistribution (#462) - #557

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
gbengaeben:fix/462-reward-distribution-tests
Jun 28, 2026
Merged

test: add unit tests for useRewardDistribution (#462)#557
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
gbengaeben:fix/462-reward-distribution-tests

Conversation

@gbengaeben

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive unit tests for the useRewardDistribution hook and related hooks (useClaimRewards, useRewardDistributionStatus, useRewardDistributionValidator).

Changes

  • Created src/hooks/__tests__/useRewardDistribution.test.ts with 33 tests covering:
    • useRewardDistribution: Initial state, wallet validation, chain ID mismatch, successful distribution with writeContract, error handling, reset
    • useClaimRewards: Successful claims, BigInt math verification, empty/invalid reward IDs, zero/negative amounts, wallet connectivity checks
    • useRewardDistributionStatus: Pending → confirming → confirmed → failed state transitions, receipt confirmations, txHash reset
    • useRewardDistributionValidator: Valid claims, empty rewards, zero amount, minimum amount threshold, duplicate ID detection
  • Uses mocked wagmi/viem providers for accurate BigInt math verification
  • All tests use renderHook from @testing-library/react

Closes #462

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@gbengaeben Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown
Contributor

Nice test addition. Merging.

@nanaf6203-bit
nanaf6203-bit merged commit ecef30a into MettaChain:main Jun 28, 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.

testing: add unit tests for useRewardDistribution

2 participants