> For the complete documentation index, see [llms.txt](https://docs.maple.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maple.finance/technical-resources/security/testing.md).

# Testing

The protocol contracts are tested with Foundry in a single repository that imports every protocol module as a submodule. This page describes the test suites and how to run them. Maple produces the full test output for each release.

## Test suites

Counts are taken from the November 2026 release sources. A test is a `test`, `invariant` or `statefulFuzz` function in a `.t.sol` file.

| Suite            | Path                     | Files | Tests | What it covers                                                                                                                                                                                                                                                                                                                                                                                       |
| ---------------- | ------------------------ | ----- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Integration      | `tests/integration`      | 88    | 1,297 | Each external function of each contract, including access control, pause checks and revert conditions. Grouped by contract: Pool, Pool Manager, Withdrawal Manager, Pool Permission Manager, Globals, Governor Timelock, Open Term Loan, Open Term Loan Manager, Strategy Manager, Liquidity Router, Aave V3, Sky and Allocation strategies, and the Syrup router.                                   |
| Fuzz             | `tests/fuzz`             | 23    | 59    | Randomised inputs for Pool accounting, open-term loans and the three underlying strategies.                                                                                                                                                                                                                                                                                                          |
| Invariants       | `tests/invariants`       | 9     | 8     | Stateful fuzzing. Handlers perform random sequences of deposits, fundings, redemptions, impairments, losses and yield, and the properties on the [Invariants](https://docs.maple.finance/technical-resources/security/protocol-invariants.md) page are asserted after every step.                                                                                                                    |
| End-to-end       | `tests/e2e`              | 25    | 61    | Multi-step scenarios: deployment configurations, several Pools sharing one Strategy Manager, impairment and recovery, fee collection and rate changes, and underlying protocol outages such as a halted Sky PSM.                                                                                                                                                                                     |
| Protocol upgrade | `tests/protocol-upgrade` | 32    | 78    | Rehearsals of mainnet upgrades on a fork, including the full November 2026 upgrade procedure and compatibility of existing Pools after it.                                                                                                                                                                                                                                                           |
| Health checkers  | `tests/health-checkers`  | 1     | 1     | The health checker contracts in `contracts/health-checkers/` used by [Critical Monitoring](https://docs.maple.finance/technical-resources/security/security.md#critical-monitoring). `tests/health-checkers/ModularReleaseHealthCheckers.t.sol` runs them on a mainnet fork after the November 2026 upgrade, and `tests/invariants/HealthCheckerInvariants.t.sol` runs them during stateful fuzzing. |
| Scenarios        | `scenarios`              | 1     | 1     | A runner that replays Pool and loan scenarios defined as CSV files.                                                                                                                                                                                                                                                                                                                                  |

Tests named `testFork_`, and suites that extend a fork test base, run against a mainnet fork. The Aave V3 and Sky strategy tests use the live Aave and Sky contracts this way.

## Running the tests

Install the submodules and build first.

```
make install
make build
```

Each suite has a make target. Fork tests read the mainnet RPC endpoint from `ETH_RPC_URL`, and the crosschain upgrade tests read `ALCHEMY_API_KEY`.

| Command                              | Runs                                    |
| ------------------------------------ | --------------------------------------- |
| `make test`                          | Every test under `tests/`               |
| `make integration`                   | `tests/integration`                     |
| `make fuzz`                          | `tests/fuzz`                            |
| `make invariant`                     | `tests/invariants`                      |
| `make e2e`                           | `tests/e2e`                             |
| `make protocol-upgrade`              | `tests/protocol-upgrade`                |
| `make scenario-v2`                   | Every CSV scenario under `scenarios/v2` |
| `./test.sh -d tests/health-checkers` | `tests/health-checkers`                 |

The suite targets accept a Foundry profile. `make fuzz profile=deep` raises fuzz runs to 500 and invariant depth to 250, and `profile=super_deep` raises fuzz runs to 5,000 and invariant runs to 200.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maple.finance/technical-resources/security/testing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
