test(fee): add unit and integration tests for protocol fee calculation at edge supply values (#557)#593
Open
TheDEV111 wants to merge 1 commit into
Open
test(fee): add unit and integration tests for protocol fee calculation at edge supply values (#557)#593TheDEV111 wants to merge 1 commit into
TheDEV111 wants to merge 1 commit into
Conversation
Author
|
@Chucks1093 kindly review |
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.
Summary
Fixes #557
This PR adds unit and integration test coverage to verify that the protocol fee is calculated correctly across key supply edge cases — specifically at supply 0 (first key), supply 1, and supply 1000. It also enforces that fee calculations dynamically use the configured fee basis points from the test environment rather than hardcoded percentages, and verifies floor rounding (truncation towards zero) when protocol fee calculations produce non-integer stroop amounts.
Changes Included
creator-keys/tests/protocol_fee_supply_edge_cases.rs:test_protocol_fee_at_supply_0: Asserts protocol fee calculation when total key supply is 0 (first key buy quote & fee split).test_protocol_fee_at_supply_1: Asserts protocol fee calculation when key supply is 1.test_protocol_fee_at_supply_1000: Asserts protocol fee calculation at large supply (1000 keys).test_protocol_fee_rounding_is_floor_not_ceiling: Verifies floor rounding behavior when the calculated fee contains a fractional stroop amount (e.g. 999 stroops @ 10% fee -> 99 stroops, 1 stroop @ 10% fee -> 0 stroops, 1001 stroops @ 10% fee -> 100 stroops).test_apply_percentage_fee_uses_configured_bps_and_floors: Directly unit testsfee::apply_percentage_feeacross multiple fee configurations (500 bps, 1000 bps, 2500 bps).Acceptance Criteria Verification
CI / Testing
cargo fmt --all -- --checkpassedcargo clippy --workspace --all-targets -- -D warningspassed cleanlycargo test --workspacepassed (all workspace tests passing)cargo check --workspacepassed