test

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WasmGasLimitInstantiate uint64 = 1_000_000
	WasmGasLimitExecute     uint64 = 10_000_000
	WasmGasLimitQuery       uint64 = 200_000
)

rough gas limits for wasm execution - used in tests only

Variables

This section is empty.

Functions

func AssertWasmCounterState

func AssertWasmCounterState(
	s *suite.Suite,
	deps evmtest.TestDeps,
	wasmContract sdk.AccAddress,
	wantCount int64,
)

From IWasm.query of Wasm.sol:

```solidity
function query(
  string memory contractAddr,
  bytes memory req
) external view returns (bytes memory response);
```

func AssertWasmCounterStateWithEvm

func AssertWasmCounterStateWithEvm(
	s *suite.Suite,
	deps evmtest.TestDeps,
	evmObj *vm.EVM,
	wasmContract sdk.AccAddress,
	wantCount int64,
)

func IncrementWasmCounterWithExecuteMulti

func IncrementWasmCounterWithExecuteMulti(
	s *suite.Suite,
	deps *evmtest.TestDeps,
	evmObj *vm.EVM,
	wasmContract sdk.AccAddress,
	times uint,
	commit bool,
)

From evm/embeds/contracts/Wasm.sol:

```solidity
struct WasmExecuteMsg {
  string contractAddr;
  bytes msgArgs;
  BankCoin[] funds;
}

/// @notice Identical to "execute", except for multiple contract calls.
function executeMulti(
  WasmExecuteMsg[] memory executeMsgs
) payable external returns (bytes[] memory responses);
```

The increment call corresponds to the ExecuteMsg from the hello_world_counter Wasm contract:

```rust
#[cw_serde]
pub enum ExecuteMsg {
    Increment {},         // Increase count by 1
    Reset { count: i64 }, // Reset to any i64 value
}
```

func SetupWasmContracts

func SetupWasmContracts(deps *evmtest.TestDeps, s *suite.Suite) (
	contracts []sdk.AccAddress,
)

SetupWasmContracts stores all Wasm bytecode and has the "deps.Sender" instantiate each Wasm contract using the precompile.

Types

type QueryMsgCountResp

type QueryMsgCountResp struct {
	Count int64  `json:"count"`
	Owner string `json:"owner"`
}

Result of QueryMsg::Count from the hello_world_counter Wasm contract:

```rust
#[cw_serde]
pub struct State {
    pub count: i64,
    pub owner: Addr,
}
```

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL