diff --git a/src/pages/cw-multi-test/_meta.js b/src/pages/cw-multi-test/_meta.js index 20a531f6..bf204bad 100644 --- a/src/pages/cw-multi-test/_meta.js +++ b/src/pages/cw-multi-test/_meta.js @@ -4,6 +4,18 @@ export default { "getting-started": "Getting started", app: "App", "app-builder": "AppBuilder", + contract: "Contract", + "contract-wrapper": "ContractWrapper", blocks: "Blocks", + api: "API", addresses: "Addresses", + storage: "Storage", + bank: "Bank", + staking: "Staking", + distribution: "Distribution", + governance: "Governance", + stargate: "Stargate", + wasm: "Wasm", + custom: "Custom", + ibc: "IBC", }; diff --git a/src/pages/cw-multi-test/api.mdx b/src/pages/cw-multi-test/api.mdx new file mode 100644 index 00000000..7225c7c7 --- /dev/null +++ b/src/pages/cw-multi-test/api.mdx @@ -0,0 +1,19 @@ +--- +tags: ["multitest", "API"] +--- + +# API + +## Initialization with the default API + +- `App::default(){:rust}` +- `app.api(){:rust}` +- `MockApi{:rust}` +- `MockApiBech32{:rust}` +- `MockApiBech32m{:rust}` +- custom API example? - maybe in the next version + +```rust copy showLineNumbers +let app = App::default(); +app.api(); +``` diff --git a/src/pages/cw-multi-test/app.mdx b/src/pages/cw-multi-test/app.mdx index aef98843..a90d925c 100644 --- a/src/pages/cw-multi-test/app.mdx +++ b/src/pages/cw-multi-test/app.mdx @@ -76,3 +76,59 @@ assert_eq!("20OSMO", my_coins[0].to_string()); The [`no_init{:rust}`][no_init] function serves as an empty chain initialization callback, offering a convenient option when no specific chain initialization is required. Usually used when calling [`App::new{:rust}`][new] or [`AppBuilder::build{:rust}`][build] methods. + +## `custom_app` + +(WIP) + +## `init_modules` + +(WIP) + +## `store_code` + +(WIP) + +## `store_code_with_creator` + +(WIP) + +## `store_code_with_id` + +(WIP) + +## `duplicate_code` + +(WIP) + +## `contract_data` + +(WIP) + +## `dump_wasm_raw` + +(WIP) + +## `contract_storage` + +(WIP) + +## `contract_storage_mut` + +(WIP) + +## `prefixed_storage` + +(WIP) + +## `prefixed_storage_mut` + +(WIP) + +## `prefixed_multilevel_storage` + +(WIP) + +## `prefixed_multilevel_storage_mut` + +(WIP) diff --git a/src/pages/cw-multi-test/bank.mdx b/src/pages/cw-multi-test/bank.mdx new file mode 100644 index 00000000..6498607c --- /dev/null +++ b/src/pages/cw-multi-test/bank.mdx @@ -0,0 +1,18 @@ +--- +tags: ["multitest", "bank"] +--- + +# Bank + +- `BankKeeper{:rust}` (default implementation) + +--- + +- `BankMsg::Send{:rust}` +- `BankMsg::Burn{:rust}` +- `BankQuery::AllBalances{:rust}` +- `BankQuery::Balance{:rust}` +- `BankQuery::Supply{:rust}` +- `BankQuery::DenomMetadata{:rust}` +- `BankQuery::AllDenomMetadata{:rust}` +- `BankSudo::Mint{:rust}` diff --git a/src/pages/cw-multi-test/contract-wrapper.mdx b/src/pages/cw-multi-test/contract-wrapper.mdx new file mode 100644 index 00000000..838f43f6 --- /dev/null +++ b/src/pages/cw-multi-test/contract-wrapper.mdx @@ -0,0 +1,27 @@ +--- +tags: ["multitest", "ContractWrapper"] +--- + +# `ContractWrapper` + +- new +- new_with_empty +- with_reply +- with_reply_empty +- with_migrate +- with_migrate_empty +- with_sudo +- with_sudo_empty + +```rust +fn counter_contract() -> Box> { + Box::new(ContractWrapper::new_with_empty( + counter::contract::execute, + counter::contract::instantiate, + counter::contract::query, + )) +} +``` + +[`ContractWrapper`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.ContractWrapper.html) +in crate documentation diff --git a/src/pages/cw-multi-test/contract.mdx b/src/pages/cw-multi-test/contract.mdx new file mode 100644 index 00000000..702d09a4 --- /dev/null +++ b/src/pages/cw-multi-test/contract.mdx @@ -0,0 +1,47 @@ +--- +tags: ["multitest", "Contract"] +--- + +# `Contract` + +- execute +- instantiate +- query +- sudo +- reply +- migrate +- checksum + +```rust +pub trait Contract +where + C: CustomMsg, + Q: CustomQuery, +{ + /// Evaluates contract's `execute` entry-point. + fn execute(&self, deps: DepsMut, env: Env, info: MessageInfo, msg: Vec) -> AnyResult>; + + /// Evaluates contract's `instantiate` entry-point. + fn instantiate(&self, deps: DepsMut, env: Env, info: MessageInfo, msg: Vec) -> AnyResult>; + + /// Evaluates contract's `query` entry-point. + fn query(&self, deps: Deps, env: Env, msg: Vec) -> AnyResult; + + /// Evaluates contract's `sudo` entry-point. + fn sudo(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult>; + + /// Evaluates contract's `reply` entry-point. + fn reply(&self, deps: DepsMut, env: Env, msg: Reply) -> AnyResult>; + + /// Evaluates contract's `migrate` entry-point. + fn migrate(&self, deps: DepsMut, env: Env, msg: Vec) -> AnyResult>; + + /// Returns the provided checksum of the contract's Wasm blob. + fn checksum(&self) -> Option { + None + } +} +``` + +[`Contract`](https://docs.rs/cw-multi-test/latest/cw_multi_test/trait.Contract.html) in crate +documentation diff --git a/src/pages/cw-multi-test/custom.mdx b/src/pages/cw-multi-test/custom.mdx new file mode 100644 index 00000000..8892ab8c --- /dev/null +++ b/src/pages/cw-multi-test/custom.mdx @@ -0,0 +1,7 @@ +--- +tags: ["multitest", "custom"] +--- + +# Custom + +- `FailingModule{:rust}` (default implementation) diff --git a/src/pages/cw-multi-test/distribution.mdx b/src/pages/cw-multi-test/distribution.mdx new file mode 100644 index 00000000..c8c81260 --- /dev/null +++ b/src/pages/cw-multi-test/distribution.mdx @@ -0,0 +1,12 @@ +--- +tags: ["multitest", "distribution"] +--- + +# Distribution + +- `DistributionKeeper{:rust}` (default implementation) + +--- + +- `DistributionMsg::WithdrawDelegatorReward{:rust}` +- `DistributionMsg::SetWithdrawAddress{:rust}` diff --git a/src/pages/cw-multi-test/features.mdx b/src/pages/cw-multi-test/features.mdx index aca150cf..17f63d30 100644 --- a/src/pages/cw-multi-test/features.mdx +++ b/src/pages/cw-multi-test/features.mdx @@ -15,19 +15,19 @@ you can provide your own, using `AppBuilder`'s function listed in **AppBuilder&n column. Names of **`MultiTest`** feature flags required to enable specific functionality are shown in the column **Feature flag**. -| Feature | Default
implementation | Feature
flag | AppBuilder
constructor | Functionality | -| ---------------- | ---------------------------------------------------------------------------------------------------------------- | :--------------: | ---------------------------------------------------- | -------------------------------------------------- | -| [Blocks](blocks) | [`mock_env().block{:rust}`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/testing/fn.mock_env.html) | | [`with_block`](app-builder#with_block) | Operations on blocks. | -| API | [`MockApi{:rust}`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/testing/struct.MockApi.html) | | [`with_api`](app-builder#with_api) | Access to CosmWasm API. | -| Storage | [`MockStorage{:rust}`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/testing/type.MockStorage.html) | | [`with_storage`](app-builder#with_storage) | Access to storage. | -| Bank | [`BankKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.BankKeeper.html) | | [`with_bank`](app-builder#with_bank) | Interactions with **Bank** module. | -| Staking | [`StakeKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.StakeKeeper.html) | `staking` | [`with_staking`](app-builder#with_staking) | Interactions with **Staking** module. | -| Distribution | [`DistributionKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.DistributionKeeper.html) | `staking` | [`with_distribution`](app-builder#with_distribution) | Interactions with **Distribution** module. | -| Governance | [`GovFailingModule{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/type.GovFailingModule.html) | | [`with_gov`](app-builder#with_gov) | Interactions with **Governance** module. | -| Stargate | [`StargateFailing{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.StargateFailing.html) | `stargate` | [`with_stargate`](app-builder#with_stargate) | Operations using `Stargate` and/or `Any` messages. | -| Wasm | [`WasmKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.WasmKeeper.html) | | [`with_wasm`](app-builder#with_wasm) | Interactions with **Wasm** module. | -| Custom | [`FailingModule{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.FailingModule.html) | | [`new_custom`](app-builder#new_custom) | Operations using custom module. | -| IBC | [`IbcFailingModule{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/type.IbcFailingModule.html) | `stargate` | [`with_ibc`](app-builder#with_ibc) | Inter-blockchain communication operations. | +| Feature | Default
implementation | Feature
flag | AppBuilder
constructor | Functionality | +| ---------------------------- | ---------------------------------------------------------------------------------------------------------------- | :--------------: | ---------------------------------------------------- | -------------------------------------------------- | +| [Blocks](blocks) | [`mock_env().block{:rust}`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/testing/fn.mock_env.html) | | [`with_block`](app-builder#with_block) | Operations on blocks. | +| [API](api) | [`MockApi{:rust}`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/testing/struct.MockApi.html) | | [`with_api`](app-builder#with_api) | Access to CosmWasm API. | +| [Storage](storage) | [`MockStorage{:rust}`](https://docs.rs/cosmwasm-std/latest/cosmwasm_std/testing/type.MockStorage.html) | | [`with_storage`](app-builder#with_storage) | Access to storage. | +| [Bank](bank) | [`BankKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.BankKeeper.html) | | [`with_bank`](app-builder#with_bank) | Interactions with **Bank** module. | +| [Staking](staking) | [`StakeKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.StakeKeeper.html) | `staking` | [`with_staking`](app-builder#with_staking) | Interactions with **Staking** module. | +| [Distribution](distribution) | [`DistributionKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.DistributionKeeper.html) | `staking` | [`with_distribution`](app-builder#with_distribution) | Interactions with **Distribution** module. | +| [Governance](governance) | [`GovFailingModule{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/type.GovFailingModule.html) | | [`with_gov`](app-builder#with_gov) | Interactions with **Governance** module. | +| [Stargate](stargate) | [`StargateFailing{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.StargateFailing.html) | `stargate` | [`with_stargate`](app-builder#with_stargate) | Operations using `Stargate` and/or `Any` messages. | +| [Wasm](wasm) | [`WasmKeeper{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.WasmKeeper.html) | | [`with_wasm`](app-builder#with_wasm) | Interactions with **Wasm** module. | +| [Custom](custom) | [`FailingModule{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/struct.FailingModule.html) | | [`new_custom`](app-builder#new_custom) | Operations using custom module. | +| [IBC](ibc) | [`IbcFailingModule{:rust}`](https://docs.rs/cw-multi-test/latest/cw_multi_test/type.IbcFailingModule.html) | `stargate` | [`with_ibc`](app-builder#with_ibc) | Inter-blockchain communication operations. | ## Feature flags summary diff --git a/src/pages/cw-multi-test/governance.mdx b/src/pages/cw-multi-test/governance.mdx new file mode 100644 index 00000000..82390c35 --- /dev/null +++ b/src/pages/cw-multi-test/governance.mdx @@ -0,0 +1,22 @@ +--- +tags: ["multitest", "governance"] +--- + +import { Callout } from "nextra/components"; + +# Governance + +- `GovFailingModule{:rust}` (default implementation) +- `GovAcceptingModule{:rust}` + +--- + +- `GovMsg::Vote{:rust}` +- `GovMsg::VoteWeighted{:rust}` + +--- + + + This seems to be a straightforward case where we can demonstrate how to implement a 'module' and + use it in tests, even when no default implementation is provided in **`MultiTest`**. + diff --git a/src/pages/cw-multi-test/ibc.mdx b/src/pages/cw-multi-test/ibc.mdx new file mode 100644 index 00000000..0373babd --- /dev/null +++ b/src/pages/cw-multi-test/ibc.mdx @@ -0,0 +1,24 @@ +--- +tags: ["multitest", "IBC"] +--- + +# IBC + +- `IbcFailingModule{:rust}` (default implementation) +- `IbcAcceptingModule{:rust}` + +--- + +- `IbcMsg::Transfer{:rust}` +- `IbcMsg::SendPacket{:rust}` +- `IbcMsg::WriteAcknowledgement{:rust}` +- `IbcMsg::CloseChannel{:rust}` +- `IbcMsg::PayPacketFee{:rust}` +- `IbcMsg::PayPacketFeeAsync{:rust}` + +--- + +- `IbcQuery::PortId{:rust}` +- `IbcQuery::ListChannels{:rust}` +- `IbcQuery::Channel{:rust}` +- `IbcQuery::FeeEnabledChannel{:rust}` diff --git a/src/pages/cw-multi-test/staking.mdx b/src/pages/cw-multi-test/staking.mdx new file mode 100644 index 00000000..c4ccc52a --- /dev/null +++ b/src/pages/cw-multi-test/staking.mdx @@ -0,0 +1,18 @@ +--- +tags: ["multitest", "staking"] +--- + +# Staking + +- `StakeKeeper{:rust}` (default implementation) + +--- + +- `StakingMsg::Delegate{:rust}` +- `StakingMsg::Undelegate{:rust}` +- `StakingMsg::Redelegate{:rust}` +- `StakingQuery::BondedDenom{:rust}` +- `StakingQuery::Delegation{:rust}` +- `StakingQuery::AllValidators{:rust}` +- `StakingQuery::Validator{:rust}` +- `StakingSudo::Slash{:rust}` diff --git a/src/pages/cw-multi-test/stargate.mdx b/src/pages/cw-multi-test/stargate.mdx new file mode 100644 index 00000000..f7d595af --- /dev/null +++ b/src/pages/cw-multi-test/stargate.mdx @@ -0,0 +1,12 @@ +--- +tags: ["multitest", "stargate"] +--- + +# Stargate + +- `StargateFailing{:rust}` (default implementation) +- `StargateAccepting{:rust}` + +--- + +- Stargate trait diff --git a/src/pages/cw-multi-test/storage.mdx b/src/pages/cw-multi-test/storage.mdx new file mode 100644 index 00000000..bdf7a35f --- /dev/null +++ b/src/pages/cw-multi-test/storage.mdx @@ -0,0 +1,19 @@ +--- +tags: ["multitest", "storage"] +--- + +# Storage + +## Initialization with the default storage + +(some description) + +- `App::default(){:rust}` +- `app.storage(){:rust}` +- `app.storage_mut(){:rust}` + +```rust +let app = App::default(); +app.storage(); +app.storage_mut(); +``` diff --git a/src/pages/cw-multi-test/wasm.mdx b/src/pages/cw-multi-test/wasm.mdx new file mode 100644 index 00000000..7cacc207 --- /dev/null +++ b/src/pages/cw-multi-test/wasm.mdx @@ -0,0 +1,20 @@ +--- +tags: ["multitest", "wasm"] +--- + +# Wasm + +- `WasmKeeper{:rust}` (default implementation) + +--- + +- `WasmMsg::Execute{:rust}` +- `WasmMsg::Instantiate{:rust}` +- `WasmMsg::Instantiate2{:rust}` +- `WasmMsg::Migrate{:rust}` +- `WasmMsg::UpdateAdmin{:rust}` +- `WasmMsg::ClearAdmin{:rust}` +- `WasmQuery::Smart{:rust}` +- `WasmQuery::Raw{:rust}` +- `WasmQuery::ContractInfo{:rust}` +- `WasmQuery::CodeInfo{:rust}`