Skip to content

Add unit tests for the buy function emitting a KeyPurchased event with the correct new supply after each purchase #698

Description

@Chucks1093

Summary

The KeyPurchased event emitted on each buy should reflect the supply after the purchase, not before. Unit tests should confirm the new_supply field in the event matches the on-chain supply after the transaction and increments correctly across sequential buys.

Scope

  • Test a single buy from supply 0 emits KeyPurchased with new_supply: 1
  • Test buying 5 keys from supply 10 emits KeyPurchased with new_supply: 15
  • Test two sequential buys emit two events with new_supply incrementing correctly
  • Assert new_supply in the event equals the supply returned by get_total_supply after the call
  • Assert no event emitted on a failed buy

Acceptance Criteria

  • new_supply in event equals post-buy on-chain supply
  • Sequential buys emit events with correctly incrementing new_supply
  • No event emitted on failed buy
  • Event new_supply matches get_total_supply return value

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions