Skip to content

[Docs] Add comprehensive guide for testing cross-contract calls with MockEnv #780

Description

@ekelemepraise-code

Summary

Cross-contract call testing is one of the most requested documentation topics but currently only has a bare-bones example in the examples/cross-contract/ directory. The README does not explain the setup pattern at all.

What's Needed

A full guide section covering:

  1. Registering multiple contracts in a single MockEnv
  2. Passing contract IDs between contracts in tests
  3. Asserting events from inner contracts when an outer contract triggers them
  4. Authorization chains — how mock_all_auths propagates through cross-contract calls
  5. Debugging tips — reading nested call traces

Proposed Structure

Add a new section to README.md:

### Testing Cross-Contract Calls

#### Registering Dependent Contracts
...

#### Routing Contract IDs
...

#### Event Assertions in Nested Calls
...

Also expand examples/cross-contract/src/test.rs with a realistic multi-level call scenario (e.g., Aggregator → AMM Pool → Token).

Acceptance Criteria

  • README section added with working code examples
  • examples/cross-contract test expanded
  • All code examples compile with cargo test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions