test: add new_supply to KeysBoughtEvent and unit tests for buy event supply tracking - #711
Merged
Chucks1093 merged 3 commits intoAug 24, 2026
Conversation
…event supply tracking Closes accesslayerorg#698 Add new_supply: u32 to KeysBoughtEvent so the buy event reflects the total supply after the purchase rather than before. Update the buy function in lib.rs to populate new_supply from the already-incremented profile.supply value. Add creator-keys/tests/key_purchased_new_supply.rs covering all four acceptance criteria: - Single buy from supply 0 emits new_supply: 1 - Buy from supply 10 emits new_supply: 11 - Two sequential buys emit incrementing new_supply (1, then 2) - Five sequential buys each match get_total_key_supply after the call - No buy event is emitted when the buy fails (insufficient payment) - new_supply in the event equals get_total_key_supply after each buy Also update BUY_EVENT_DATA_FIELDS to include "new_supply" and align the field-order assertion and supply-tracking test in tests/events.rs.
Member
|
This is a solid change. Including new_supply directly in the buy event removes any guesswork about the supply state after a purchase and the sequential buy tests give good confidence that the value is always accurate. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #698
Summary
new_supply: u32toKeysBoughtEventso the buy event reflects the total supply after the purchase (not before).buy_keyinlib.rsto populatenew_supplyfrom the already-incrementedprofile.supplyvalue.BUY_EVENT_DATA_FIELDSconst to include"new_supply".creator-keys/tests/key_purchased_new_supply.rswith unit tests covering all four acceptance criteria.tests/events.rs.Test plan
new_supply: 1new_supply: 11new_supply: 1, thennew_supply: 2new_supplymatchesget_total_key_supplyafter the callnew_supplyin event equalsget_total_key_supplyreturn value after every buy