Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polishing improvements #128

Merged
merged 7 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions src/pages/cw-multi-test.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,37 @@ tags: ["multitest"]

import { Callout } from "nextra/components";

[file an issue]: https://github.com/CosmWasm/cw-multi-test/issues

# Introduction

**`MultiTest`** is a suite of testing tools designed for facilitating multi-contract interactions
**`MultiTest`** is a suite of testing tools designed to facilitate multi-contract interactions
within the CosmWasm ecosystem. Its primary focus is on providing developers with a robust framework
for testing complex contract interactions and several Cosmos modules operations.
for testing complex smart contract interactions and operations involving various Cosmos modules.

<Callout type="info">
MultiTest is a **simulator** of the blockchain, allowing tested smart contracts to interact as if
they were operating on the real-life blockchain.
**`MultiTest`** is a blockchain **SIMULATOR**, allowing tested smart contracts to interact as if
they were operating on a real blockchain.
</Callout>

The most valuable advantage of using **`MultiTest`** is that it allows you to test and debug smart
contracts with access to Rust source code, eliminating the need to run a complete blockchain node to
begin designing smart contract functionality.
The most valuable advantage of using **`MultiTest`** is that it allows testing and debugging of
DariuszDepta marked this conversation as resolved.
Show resolved Hide resolved
smart contracts with access to the Rust source code, eliminating the need to run a complete
blockchain node to begin designing the smart contract functionality. Additionally, **`MultiTest`**
enables the execution of tests significantly faster than on a real blockchain, as it bypasses the
overhead associated with network consensus and block production. This results in a more efficient
development cycle, allowing for quicker iterations and faster identification of issues.

While **`MultiTest`** is a blockchain **SIMULATOR**, it may happen, that the behavior of the real
blockchain might slightly differ in some edge cases. We strongly encourage you to [file an issue]
with a detailed description of such use case to help us improve the **`MultiTest`**.

The disadvantage is that **`MultiTest`** is a blockchain simulator, and it is possible that the
behavior of the real-life blockchain may slightly differ in edge cases from the simulated model. In
such cases, we strongly encourage you to
[file an issue](https://github.com/CosmWasm/cw-multi-test/issues) with a detailed description of the
use case to help us improve **`MultiTest`**.
In the upcoming chapters, we provide detailed instructions on installing and getting started with
**`MultiTest`**, writing unit tests for smart contracts, testing complex interactions between smart
contracts and testing smart contract interactions with Cosmos modules.

In the upcoming chapters, we will provide detailed instructions on installing and getting started
with **`MultiTest`**, writing unit tests for smart contracts, testing complex interactions between
smart contracts and testing smart contract interactions with Cosmos modules.
By the end of these chapters, you will have a comprehensive understanding of how to use
**`MultiTest`** for testing and debugging smart contracts in various scenarios.

By the end of these chapters, you will have a comprehensive understanding of using **`MultiTest`**
for testing and debugging smart contracts in various scenarios.
<Callout>
To successfully follow the upcoming chapters, a basic knowledge of Rust and Cargo is required.
</Callout>
37 changes: 22 additions & 15 deletions src/pages/cw-multi-test/features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,30 @@ tags: ["multitest", "features"]

# Features

## Functionalities
All **`MultiTest`** features a listed in the following table. The **"Default implementation"**
column indicates whether the feature has a default implementation in **`MultiTest`** that simulates
the functionality of the real blockchain as closely as possible. In cases where **`MultiTest`** does
not have a default implementation for the feature, users may provide their own, using `AppBuilder`'s
function listed in **"AppBuilder constructor"** column. Names of **`MultiTest`** feature flags
required to enable specific functionality are provided in the column **"Feature flag"**.

| Functionality | Impl | Feature | AppBuilder | Testing purpose |
| ------------- | ------- | ---------- | ------------------- | ------------------------------------------- |
| Block | **YES** | | `with_block` | Operations on blocks. |
| API | **YES** | | `with_api` | Access to CosmWasm API. |
| Storage | **YES** | | `with_storage` | Access to storage. |
| Bank | **YES** | | `with_bank` | Interactions with **Bank** module. |
| Staking | **YES** | `staking` | `with_staking` | Interactions with **Staking** module. |
| Distribution | **YES** | `staking` | `with_distribution` | Interactions with **Distribution** module. |
| Governance | **NO** | | `with_gov` | Interactions with **Governance** module. |
| Stargate | **NO** | `stargate` | `with_stargate` | Operations with <br/>Stargate/Any messages. |
| Wasm | **YES** | | `with_wasm` | Interactions with **Wasm** module. |
| Custom | **NO** | | `new_custom` | Operations on custom module. |
| IBC | **NO** | `stargate` | `with_ibc` | Inter-blockchain communication operations. |
| Feature | Default<br/>implementation | Feature<br/>flag | AppBuilder<br/>constructor | Functionality |
| ------------ | :------------------------: | :--------------: | -------------------------- | -------------------------------------------------- |
| Block | **YES** | | `with_block` | Operations on blocks. |
| API | **YES** | | `with_api` | Access to CosmWasm API. |
| Storage | **YES** | | `with_storage` | Access to storage. |
| Bank | **YES** | | `with_bank` | Interactions with **Bank** module. |
| Staking | **YES** | `staking` | `with_staking` | Interactions with **Staking** module. |
| Distribution | **YES** | `staking` | `with_distribution` | Interactions with **Distribution** module. |
| Governance | **NO** | | `with_gov` | Interactions with **Governance** module. |
| Stargate | **NO** | `stargate` | `with_stargate` | Operations using `Stargate` and/or `Any` messages. |
| Wasm | **YES** | | `with_wasm` | Interactions with **Wasm** module. |
| Custom | **NO** | | `new_custom` | Operations using custom module. |
| IBC | **NO** | `stargate` | `with_ibc` | Inter-blockchain communication operations. |

## Feature flags
## Feature flags summary

The following table summarizes all the feature flags supported by **`MultiTest`**.

| Feature flag | Description |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
31 changes: 20 additions & 11 deletions src/pages/cw-multi-test/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,41 @@ tags: ["multitest", "installation"]

import { Callout } from "nextra/components";

[rustup installer]: https://rustup.rs
[Rust and Cargo]: https://www.rust-lang.org/tools/install
[Tarpaulin]: https://github.com/xd009642/tarpaulin
[Nextest]: https://nexte.st
[cw-multi-test]: https://crates.io/crates/cw-multi-test

# Installation

**`MultiTest`** ships as a Rust library named
[cw-multi-test](https://crates.io/crates/cw-multi-test).
**`MultiTest`** ships as a Rust library named [cw-multi-test].

To use **`MultiTest`** for building and testing smart contracts, add it as a **development
dependency** to your project:
To use **`MultiTest`** for testing smart contracts, add it as a **DEVELOPMENT DEPENDENCY** to your
project:

```toml filename="Cargo.toml"
[dev-dependencies]
cw-multi-test = "2"
```

<Callout emoji="🚨">
**`MultiTest`** is a _**testing**_ library and should always be added to your project as
**`MultiTest`** is a **TESTING** library and should always be added to your project as
**DEVELOPMENT DEPENDENCY** in section **`[dev-dependencies]`** of the **Cargo.toml** file.
</Callout>

### Prerequisities
## Prerequisities

The only prerequisite to test smart contracts using **`MultiTest`** is having [Rust and Cargo]
installed.

The only prerequisite to build and test smart contracts using **`MultiTest`** is having
[Rust and Cargo](https://www.rust-lang.org/tools/install) installed.
<Callout>
We recommend installing Rust using the official [rustup installer]. This makes it easy to stay on
the most recent Rust version.
</Callout>

Optionally, you may want to install [Tarpaulin](https://github.com/xd009642/tarpaulin) for measuring
code coverage and [Nextest](https://nexte.st) for running tests faster, with clean and beautiful
user interface.
Optionally, you may want to install [Tarpaulin] for measuring code coverage and [Nextest] for
running tests faster, with clean and beautiful user interface.

Installing **Tarpaulin**:

Expand Down