Skip to content

Comments

Issue #217: Implement Cross-Contract Call Mocking#239

Merged
Timi16 merged 4 commits intoTimi16:mainfrom
Tijesunimi004:feature/217-cross-contract-mocking
Feb 23, 2026
Merged

Issue #217: Implement Cross-Contract Call Mocking#239
Timi16 merged 4 commits intoTimi16:mainfrom
Tijesunimi004:feature/217-cross-contract-mocking

Conversation

@Tijesunimi004
Copy link
Contributor

Description

This PR addresses Issue #217 by implementing the ability to mock cross-contract calls during CLI debugging sessions. It adds the infrastructure necessary to intercept host execution calls, return pre-configured mocked values, and track invocation counts.

Key Changes

  • CLI Arguments (src/cli/args.rs):
    • Added support for a repeatable --mock flag to parse CONTRACT_ID.function_name=return_value formatted arguments.
  • Host Execution Inteception (src/runtime/mocking.rs & src/runtime/executor.rs):
    • Implemented MockRegistry to store specifications and track mocked executions.
    • Introduced MockContractDispatcher to handle intercepted cross-contract calls.
    • Configured the ContractExecutor to install mock dispatchers via the Soroban host environment prior to execution.
  • Reporting (src/cli/commands.rs):
    • Updated the reporting layer to display a clean summary of what functions were mocked, how many arguments they received, and what they returned.
    • Displays clear warnings for unmocked cross-contract calls on mocked contracts.

Testing

  • Added comprehensive unit tests validating mocked resolution and logging for unmocked requests.
  • Ran cargo fmt and cargo test to ensure stability and style compliance.

Related Issues

Closes #217

@Timi16 Timi16 merged commit 2943b3a into Timi16:main Feb 23, 2026
8 checks passed
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.

Implement Cross-Contract Call Mocking

2 participants