Skip to content

Add tests for rotate_beneficiary dual-authorization and the post-rotation payout target #477

Description

@mikewheeleer

Add tests for rotate_beneficiary dual-authorization and the post-rotation payout target

Description

rotate_beneficiary(env, new_sme_address) changes who receives SME liquidity at withdraw(), under dual authorization. Beyond asserting both signatures are required, the critical end-to-end property is that after a successful rotation the withdraw actually pays the new address — a test that ties rotation to the downstream sme_wd transfer is missing, so a regression that updated the stored address but kept paying the old SME could slip through.

This issue adds an end-to-end test rotating the beneficiary and asserting the subsequent withdrawal routes funds to the new address.

Requirements and context

  • Repository scope: Liquifact/Liquifact-contracts only.
  • Assert rotation requires both current SME and admin auth (missing either fails).
  • After rotation, fund to target, settle/withdraw, and assert the token transfer credits the new SME address, not the old one.
  • Assert the ben_rot event carries old and new addresses.
  • Use a registered mock token to verify the real balance delta on withdrawal.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-rotate-beneficiary-e2e
  • Implement changes
    • Write code in: no production change expected; if a defect is found, fix it in contracts/escrow/src/lib.rs.
    • Write comprehensive tests in: contracts/escrow/src/tests/integration.rs — the rotate-then-withdraw end-to-end assertion.
    • Add documentation: note the rotation-to-payout linkage in README.md and docs/.
    • Include NatSpec-style doc comments (///) on any helper.
    • Validate security assumptions: withdrawal pays exactly the current stored beneficiary.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases and failure paths: missing SME auth, missing admin auth, withdrawal after rotation, and no rotation (baseline).
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

test: assert beneficiary rotation routes the subsequent withdrawal to the new SME

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the Liquifact community on Discord for questions, reviews, and faster merges: https://discord.gg/JrGPH4V3
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions