test(bond): enforce and verify bond lifecycle authorization boundaries #1272 - #1304
Merged
Baskarayelu merged 1 commit intoAug 29, 2026
Conversation
Prove, at the integration boundary, that every state-mutating bond lifecycle path (create_bond, top_up, cooldown request/execute, withdraw, withdraw_early, liquidate) enforces require_auth on the correct identity or admin before any state change. Unlike the happy-path suites (mock_all_auths), these tests use selective mock_auths so the host-level require_auth guards are genuinely exercised for allowed, denied, forged-identity, and cross-tenant calls, and assert explicit no-mutation guarantees for every rejected operation.
|
@olacodes-01 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! 🚀 |
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
Closes #1272
Enforce and verify the bond lifecycle caller-permission (authorization)
boundaries consistently across creation, increase, cooldown, exit, and
liquidation.
Auditing the existing entry points confirmed that every state-mutating
lifecycle path already gates itself on the correct authenticated address:
create_bondidentity.require_auth()top_up,extend_durationidentity.require_auth()request_cooldown_withdrawal/execute_cooldown_withdrawal/cancel_cooldownidentity.require_auth()withdraw/withdraw_early/withdraw_bond/request_withdrawal/renew_if_rollingidentity.require_auth()liquidate,slash,slash_bond,collect_feesadmin.require_auth()+ stored-admin checkBecause the contracts already enforce the required authorization, this change
preserves public behavior and adds focused regression coverage that proves
the invariant at the actual integration boundary — the missing guarantee the
issue asks for.
What changed
contracts/credence_bond/src/test_lifecycle_auth.rs— aself-contained authorization-boundary matrix over the lifecycle.
contracts/credence_bond/src/lib.rs.The tests use selective
mock_auths(notmock_all_auths), so thehost-level
require_authguards are genuinely exercised rather than bypassed.For each lifecycle phase, coverage includes:
address as
identityis rejected byrequire_auth.bond, cooldown, and liquidation state unchanged (explicit equality
assertions on
IdentityBond,get_cooldown_request, andis_liquidated).Required validation
The issue's required validation matrix is exercised by the new tests:
no-mutation assertions.
(e.g. a forged cooldown execution does not clear the victim's pending
request; a forged liquidate does not set the
Liquidatedflag).Commands
The workspace's host-side test infrastructure (Soroban SDK
testutils) doesnot compile in this environment due to a pre-existing
rand_core/ed25519-dalekversion conflict insoroban-env-host(the repository's CItest job is intentionally stubbed). This is unrelated to the change; the
change is
#[cfg(test)]-only and does not affect theno_std/wasm librarybuild. To run the new tests once the dependency issue is resolved:
cargo test -p credence_bond test_lifecycle_authCompatibility
response shape is modified. The change is additive (test-only).
Security assumptions
Address::require_auth, which thehost cryptographically verifies. This module verifies that every lifecycle
path invokes it on the correct address before any state mutation and that a
failure never leaks partial/unauthorized state.
Operational limitations
(no configured token) to keep the authorization invariant in focus; token
custody behavior is covered by separate integration suites.