Skip to content

test: add reentrancy-equivalent mock token tests to vault#381

Open
ChukwuemekaP1 wants to merge 3 commits into
CalloraOrg:mainfrom
ChukwuemekaP1:main
Open

test: add reentrancy-equivalent mock token tests to vault#381
ChukwuemekaP1 wants to merge 3 commits into
CalloraOrg:mainfrom
ChukwuemekaP1:main

Conversation

@ChukwuemekaP1
Copy link
Copy Markdown
Contributor

Summary

This PR adds a malicious mock token and tests to simulate a reentrancy attempt during Vault token transfers. The goal is to ensure the Vault cannot be exploited via external callbacks to corrupt state or double-spend balances.

Changes

  • Added malicious mock token in contracts/vault/src/test.rs

  • Mock token re-enters CalloraVault::deduct during transfer

  • Added tests for:

    • deduct reentrancy attempt
    • batch_deduct reentrancy attempt
  • Validated that Vault state remains consistent under attack conditions

Expected Behavior

  • Re-entrant calls are safely rejected or reverted
  • No double-spending or balance corruption occurs
  • Internal state remains deterministic after failed re-entry

Testing

cargo test -p callora-vault

All tests pass and confirm no state corruption under malicious token behavior.

Security Note

This strengthens Vault safety against reentrancy-equivalent attack vectors via external token callbacks.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

Hey @ChukwuemekaP1! 👋 It looks like this PR isn't linked to any issue.

If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g., Closes #123), or by clicking a button below:

Issue Title
#344 Vault: add reentrancy-equivalent test using a malicious mock token on deduct Link to this issue

ℹ️ Learn more about linking PRs to issues

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.

1 participant