The Mimic Protocol Test Library (@mimicprotocol/test-ts) provides tools for simulating task execution to validate expected task behavior under different scenarios.
This section describes the parameters and outputs of the runTask function.
2.1. Parameters
2.1.1. Task directory
The directory where the compiled task .wasm is located.
2.1.2. Context
The context includes the fields needed during task execution.
2.1.3. Inputs
The values for the inputs defined in the manifest. For example, if the manifest declares:
Then, the inputs may be:
2.1.4. Prices mock
The responses for the price queries made in the task.
For example, if the task does:
Then, the prices mock may be:
2.1.5. Relevant tokens mock
The responses for the relevant tokens queries made in the task.
For example, if the task does:
Then, the relevant tokens mock may be:
2.1.6. Contract calls mock
The responses for the contract calls made in the task. Only for read functions, i.e., those that are not intended to generate intents.
Note: Token decimals and symbol are sometimes queried behind the scenes and need mocks in those cases.
For example, if the task does:
Then, the calls mock may be:
2.1.7. Subgraph queries mock
The responses for the subgraph queries made in the task.
For example, if the task does:
Then, the subgraph queries mock may be:
2.2. Output
The runTask function returns an object containing the following fields:
success - Boolean. True if the execution ended properly, or false if it had an error.
timestamp - Number. Execution timestamp in milliseconds.
fuelUsed - Number. Amount of fuel used during the execution.
intents - Array of intents produced by the execution.
logs - Array of logs produced by the execution. It may include error logs.
2.2.1. Intents
The fields depend on the type of intents produced by the execution.
# Initialize a new Mimic project
npx @mimicprotocol/cli init my-automation-task && cd my-automation-task
# Test your task
yarn mimic test
const taskDir = './build'
import { Context } from '@mimicprotocol/test-ts'
const context: Context = {
user: '0xAddress',
settlers: [{ address: '0xAddress', chainId: 10 }], // One per chain used in the task
timestamp: Date.now(), // number (in milliseconds)
}