This PR resolves four critical issues related to protocol fee calculation, bonding curve sell function, TTL extension, and duplicate creator registration. All issues have been addressed with comprehensive unit and integration tests.
Status: ✅ Resolved
Implementation:
- Added comprehensive tests in
buy_protocol_fee_recipient_balance.rs - Added tests in
sell_protocol_fee_recipient_balance.rs - Tests cover:
- 5% fee (500 bps) deduction on buy transactions
- 5% fee (500 bps) deduction on sell transactions
- 0 bps fee handling (covered in
zero_creator_fee_regression.rs) - 100% fee scenarios (covered in
sell_quote_rounding.rs) - Fee accumulation and balance tracking
- Floor division behavior for fee calculation
Key Test Files:
creator-keys/tests/buy_protocol_fee_recipient_balance.rscreator-keys/tests/sell_protocol_fee_recipient_balance.rscreator-keys/tests/zero_creator_fee_regression.rscreator-keys/tests/fee_rounding_invariants.rs
Status: ✅ Resolved
Implementation:
- Added
sell_proceeds_decreasing_monotonically.rsfor boundary testing - Tests cover:
- Selling the last key (supply 1 → 0) with correct payout
- Higher supply yields lower per-key payout (bonding curve property)
- Monotonically decreasing proceeds across sequential sells
- Supply decrementation validation
Key Test Files:
creator-keys/tests/sell_proceeds_decreasing_monotonically.rscreator-keys/tests/sell_key.rs(includestest_sell_key_removes_holder_when_last_key_is_sold)
Status: ✅ Resolved
Implementation:
- Added comprehensive integration test in
ttl_extension_on_buy.rs - Tests cover:
- TTL extension when near expiry threshold
- TTL extension event emission with correct topics and payload
- TTL not extended when already above threshold
- Validation that TTL increases after buy
- Event structure validation
Key Test Files:
creator-keys/tests/ttl_extension_on_buy.rs
Status: ✅ Resolved
Implementation:
- Enhanced
creator_registration.rswith duplicate prevention tests - Tests cover:
- First registration succeeds and persists creator state
- Second registration from same wallet panics with
AlreadyRegisterederror - Different wallet can register independently
- Registration with different handle still fails for duplicate wallet
- State unchanged after duplicate attempt
- No state mutation on panic
Key Test Files:
creator-keys/tests/creator_registration.rs
- Added new documentation:
docs/bonding_curve_guide.mddocs/integration-test-guide.mddocs/storage-layout.md
- Enhanced test utilities in
contract_test_env - Added comprehensive event validation tests
- Improved fee calculation helper functions
All tests pass successfully. The test suite now includes:
- 125+ test files in
creator-keys/tests/ - 541+ snapshot test files
- Comprehensive coverage of edge cases and boundary conditions
- Merged from upstream:
accesslayerorg/accesslayer-contracts - Base branch:
main - Fast-forward merge completed successfully
- No conflicts encountered
All commits will be authored by:
- Name: devpeter
- Email: devpeter999olatunbossemma17@gmail.com