-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: add multi test utils #29
Conversation
Codecov Report
@@ Coverage Diff @@
## main #29 +/- ##
==========================================
+ Coverage 90.94% 91.03% +0.08%
==========================================
Files 27 27
Lines 2276 2276
==========================================
+ Hits 2070 2072 +2
+ Misses 206 204 -2
Continue to review full report at Codecov.
|
|
||
/// Represents the implementation of [`Module`](cw_multi_test::Module) for handling the desmos execution and query messages. | ||
#[derive(Default)] | ||
pub struct DesmosKeeper {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of implementing the whole state inside desmos chain, I make DesmosKeeper
as a module which always returns the successful response with proper events. Devs can handle event in the reply
phase as the sample.
} | ||
|
||
/// Represents failing desmos app always returning error. | ||
pub type FailingDesmosApp = BasicApp<DesmosMsg, DesmosQuery>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for testing the reply
function if the sub msg is failed.
Looks good to me! Maybe use the |
@@ -179,3 +179,7 @@ jobs: | |||
- name: Build feature (mocks) | |||
working-directory: ./packages/bindings | |||
run: cargo build --no-default-features --features mocks | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test can be removed
packages/bindings/Cargo.toml
Outdated
@@ -33,4 +35,5 @@ reactions = [] | |||
query = [] | |||
msg = [] | |||
mocks = ["query"] | |||
integration-test = ["query", "msg", "mocks"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature can be removed
integration-test = ["query", "msg", "mocks"] |
packages/bindings/src/lib.rs
Outdated
@@ -24,4 +24,7 @@ pub mod relationships; | |||
pub mod reports; | |||
#[cfg(feature = "subspaces")] | |||
pub mod subspaces; | |||
#[cfg(feature = "integration-test")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a custom feature is better to use the #[cfg(not(target_arch = "wasm32"))]
so that the testing_utils
module will be automaticaly compiled when performing the integration tests.
#[cfg(feature = "integration-test")] | |
#[cfg(not(target_arch = "wasm32"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I didn't think about it. Since it is a lib that mock desmos app for integration test, I use mocks
as its feature.
packages/bindings/Cargo.toml
Outdated
cosmwasm-std = { version = "1.0.0" } | ||
cw-multi-test = { version = "0.13.4", optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why it has conflict with test-contract
cosmwasm-std, so I make it optional and only use it when the feature is mocks
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to remove the optional
flag and the dependency requirement with the mocks
feature and on my computer running cargo build
everiting compiles correctly.
Can you tell me the command that triggers the error for you?
I'm using:
- cargo 1.61.0 (a028ae4 2022-04-29)
- rustc 1.61.0 (fe5b13d68 2022-05-18)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error happens while compileing the test contract with command cargo optimize
.
It shows error as follows:
Compiling cw-multi-test v0.13.4
error[E0432]: unresolved import `cosmwasm_std::testing`
--> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cw-multi-test-0.13.4/src/app.rs:5:19
|
5 | use cosmwasm_std::testing::{mock_env, MockApi, MockStorage};
| ^^^^^^^ could not find `testing` in `cosmwasm_std`
error[E0432]: unresolved import `cosmwasm_std::testing`
--> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cw-multi-test-0.13.4/src/wasm.rs:24:19
|
24 | use cosmwasm_std::testing::mock_wasmd_attr;
| ^^^^^^^ could not find `testing` in `cosmwasm_std`
Both cargo and rustup version on my PC are 1.64.0-nightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok found the issue, becouse cw-multi-test
is marked as dependency inisde the desmos-binding
toml it's compiled also when targeting wasm32-unknown-unknown
.
cosmwasm-std
expose the testing
module only when not compiling for wasm32-unknown-unknown
causing this compilation error.
Moving the cw-multi-test
into the dev-dependencies
will fix this issue
@@ -175,7 +175,3 @@ jobs: | |||
- name: Build feature (msg+reports) | |||
working-directory: ./packages/bindings | |||
run: cargo build --no-default-features --features msg,reports | |||
|
|||
- name: Build feature (mocks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove mocks feature building since it is the mock lib for testing and it occurs error related to cw-multi-test importing.
This PR implements
DesmosApp
for contract integration tests.