Skip to content

test: targeted-auth coverage for milestones::recover_admin (#562) - #759

Open
Chidi-Dev1 wants to merge 1 commit into
MergeFi:mainfrom
Chidi-Dev1:fix/milestones-recover-admin-targeted-auth-562
Open

Chidi-Dev1 wants to merge 1 commit into
MergeFi:mainfrom
Chidi-Dev1:fix/milestones-recover-admin-targeted-auth-562

Conversation

@Chidi-Dev1

Copy link
Copy Markdown

Summary

Fixes #562. Regression on #314.

recover_admin requires both recovery.require_auth() and new_admin.require_auth() — but the only existing call was under mock_all_auths(), so neither check was ever exercised by tests.

Changes

Three new targeted-auth tests in contracts/milestones/src/test.rs:

Test Auth provided Expected result
test_recover_admin_requires_both_recovery_and_new_admin_auth_ok recovery + new_admin succeeds, admin slot updated
test_recover_admin_rejects_recovery_only recovery only host auth error, admin unchanged
test_recover_admin_rejects_new_admin_only new_admin only host auth error, admin unchanged

Each test uses env.mock_auths() with exact fn_name and args tuple so the Soroban host actually enforces the require_auth() calls rather than bypassing them.

Testing

cargo test -p mergefi-milestones test_recover_admin

All 3 pass. No other files changed.

mock_all_auths() was the only call exercising recover_admin, which means
neither the recovery.require_auth() nor the new_admin.require_auth()
inside the function were ever actually checked.

Add three targeted-auth tests that replace that gap:
- test_recover_admin_requires_both_recovery_and_new_admin_auth_ok:
  both MockAuth entries present -> succeeds, admin slot updated.
- test_recover_admin_rejects_recovery_only:
  recovery signs but new_admin does not -> host auth error, admin unchanged.
- test_recover_admin_rejects_new_admin_only:
  new_admin signs but recovery does not -> host auth error, admin unchanged.

Each test uses env.mock_auths() with the exact fn_name and args tuple so
the Soroban host actually enforces the require_auth() calls.

Closes MergeFi#562. Regression on MergeFi#314.
@Chidi-Dev1
Chidi-Dev1 requested a review from chonilius as a code owner October 22, 2026 10:43
@drips-wave

drips-wave Bot commented Oct 22, 2026

Copy link
Copy Markdown

@Chidi-Dev1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@Chidi-Dev1 is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression on closed #314] milestones::recover_admin's only test still runs under mock_all_auths()

1 participant