-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0f48f1
commit b0c66e2
Showing
9 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod test_accepting_module; | ||
mod test_stargate_accepting_module; |
File renamed without changes.
68 changes: 68 additions & 0 deletions
68
tests/test_module/accepting_module/test_stargate_accepting_module.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use cosmwasm_std::testing::MockStorage; | ||
use cosmwasm_std::{Addr, Binary, Empty}; | ||
use cw_multi_test::{AcceptingModule, App, AppResponse, Module, StargateMsg, StargateQuery}; | ||
|
||
/// Utility function for comparing responses. | ||
fn eq(actual: AppResponse, expected: AppResponse) { | ||
assert_eq!(actual.events, expected.events); | ||
assert_eq!(actual.data, expected.data); | ||
} | ||
|
||
/// Utility function for asserting default outputs returned from accepting module. | ||
fn assert_results(accepting_module: AcceptingModule<StargateMsg, StargateQuery, Empty>) { | ||
let app = App::default(); | ||
let mut storage = MockStorage::default(); | ||
eq( | ||
AppResponse::default(), | ||
accepting_module | ||
.execute( | ||
app.api(), | ||
&mut storage, | ||
app.router(), | ||
&app.block_info(), | ||
Addr::unchecked("sender"), | ||
StargateMsg { | ||
type_url: Default::default(), | ||
value: Default::default(), | ||
}, | ||
) | ||
.unwrap(), | ||
); | ||
assert_eq!( | ||
Binary::default(), | ||
accepting_module | ||
.query( | ||
app.api(), | ||
&storage, | ||
&(*app.wrap()), | ||
&app.block_info(), | ||
StargateQuery { | ||
path: Default::default(), | ||
data: Default::default() | ||
} | ||
) | ||
.unwrap() | ||
); | ||
eq( | ||
AppResponse::default(), | ||
accepting_module | ||
.sudo( | ||
app.api(), | ||
&mut storage, | ||
app.router(), | ||
&app.block_info(), | ||
Empty {}, | ||
) | ||
.unwrap(), | ||
); | ||
} | ||
|
||
#[test] | ||
fn stargate_accepting_module_default_works() { | ||
assert_results(AcceptingModule::default()); | ||
} | ||
|
||
#[test] | ||
fn stargate_accepting_module_new_works() { | ||
assert_results(AcceptingModule::new()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod test_failing_module; | ||
mod test_stargate_failing_module; |
File renamed without changes.
65 changes: 65 additions & 0 deletions
65
tests/test_module/failing_module/test_stargate_failing_module.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use cosmwasm_std::testing::MockStorage; | ||
use cosmwasm_std::{Addr, Empty}; | ||
use cw_multi_test::{App, FailingModule, Module, StargateMsg, StargateQuery}; | ||
|
||
/// Utility function for asserting outputs returned from failing module. | ||
fn assert_results(failing_module: FailingModule<StargateMsg, StargateQuery, Empty>) { | ||
let app = App::default(); | ||
let mut storage = MockStorage::default(); | ||
assert_eq!( | ||
r#"Unexpected exec msg StargateMsg { type_url: "", value: Binary() } from Addr("sender")"#, | ||
failing_module | ||
.execute( | ||
app.api(), | ||
&mut storage, | ||
app.router(), | ||
&app.block_info(), | ||
Addr::unchecked("sender"), | ||
StargateMsg { | ||
type_url: Default::default(), | ||
value: Default::default(), | ||
} | ||
) | ||
.unwrap_err() | ||
.to_string() | ||
); | ||
assert_eq!( | ||
r#"Unexpected custom query StargateQuery { path: "", data: Binary() }"#, | ||
failing_module | ||
.query( | ||
app.api(), | ||
&storage, | ||
&(*app.wrap()), | ||
&app.block_info(), | ||
StargateQuery { | ||
path: Default::default(), | ||
data: Default::default() | ||
} | ||
) | ||
.unwrap_err() | ||
.to_string() | ||
); | ||
assert_eq!( | ||
"Unexpected sudo msg Empty", | ||
failing_module | ||
.sudo( | ||
app.api(), | ||
&mut storage, | ||
app.router(), | ||
&app.block_info(), | ||
Empty {} | ||
) | ||
.unwrap_err() | ||
.to_string() | ||
); | ||
} | ||
|
||
#[test] | ||
fn stargate_failing_module_default_works() { | ||
assert_results(FailingModule::default()); | ||
} | ||
|
||
#[test] | ||
fn stargate_failing_module_new_works() { | ||
assert_results(FailingModule::new()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
mod test_accepting_module; | ||
mod test_failing_module; | ||
mod accepting_module; | ||
mod failing_module; |