Skip to content

Add a protocol-config bounds enforcement test matrix for set_protocol_config and set_fee_config in init.rsΒ #1346

@Baskarayelu

Description

@Baskarayelu

πŸ“‹ Description

Admin config entrypoints in quicklendx-contracts/src/init.rs/lib.rs β€” set_protocol_config (min invoice amount, max due-date days, grace-period seconds) and set_fee_config (fee bps) β€” must respect bounds: MAX_FEE_BPS = 1000, MAX_DUE_DATE_DAYS = 730, MAX_GRACE_PERIOD_SECONDS. Prior work added init invariants and a dry-run preview, but a focused bounds-enforcement matrix asserting each parameter is clamped/rejected at its exact limit is not present.

Why this matters: config bounds are the guardrails on protocol-critical economics. A fee bps above the cap would let an admin overcharge every settlement; a grace period beyond the max would strand investor remedy. Pinning rejection at exactly the boundary for each parameter makes the guardrails provable, not assumed.

🎯 Requirements & Context

Functional requirements

  • Add quicklendx-contracts/src/test_config_bounds_matrix.rs asserting set_fee_config accepts MAX_FEE_BPS and rejects MAX_FEE_BPS + 1 with InvalidFeeBasisPoints.
  • Assert set_protocol_config accepts each parameter at its max and rejects one over (MAX_DUE_DATE_DAYS, MAX_GRACE_PERIOD_SECONDS, and the min-invoice-amount lower bound).
  • Assert non-admin callers are rejected before any state change.
  • Assert accepted values are actually persisted and readable via the corresponding getters.

Context & constraints

πŸ› οΈ Suggested Execution

1. Fork & branch

git checkout -b test/config-bounds-matrix

2. Implement changes

  • Build the at-limit / over-limit matrix for each parameter and the persistence assertions.
  • Doc-comment each bound under test.

3. Test & commit

cargo test -p quicklendx-contracts test_config_bounds_matrix -- --nocapture
  • Edge cases: fee bps of exactly 0 (min); min invoice amount at the lower bound; max due-date at exactly 730; all parameters set in one call.

Example commit message

test(governance): add config-bounds enforcement matrix for set_protocol_config/set_fee_config

Pins accept-at-max / reject-over-max for fee bps, due-date, grace period, and min amount.

βœ… Acceptance Criteria & Guidelines

Requirement Target
At-limit accept / over-limit reject matrix Required
Non-admin rejected before mutation Required
Accepted values persisted + readable Required
Coverage of config branches β‰₯ 95%
Docs + doc comments Required
cargo test + cargo clippy clean Required
Timeframe 96 hours from assignment

πŸ’¬ Community & Support

Questions, design discussion, and help getting your environment running β€” join the QuickLendX contributor community on Discord: https://discord.gg/VpngvTjWa

Please drop a note in the channel when you pick this up so we can avoid duplicate work and unblock you fast. Clear communication during the PR keeps the review fast and friction-free. πŸš€

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions