-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
use crate::helpers::mock_messages::{get_controller_inst_msg, CreateStreamMsgBuilder}; | ||
Check failure on line 1 in tests/src/tests/controller_tests/list_streams.rs GitHub Actions / Lints
|
||
use crate::helpers::suite::{Suite, SuiteBuilder}; | ||
Check failure on line 2 in tests/src/tests/controller_tests/list_streams.rs GitHub Actions / Lints
|
||
use crate::helpers::utils::get_wasm_attribute_with_key; | ||
Check failure on line 3 in tests/src/tests/controller_tests/list_streams.rs GitHub Actions / Lints
|
||
#[cfg(test)] | ||
use cosmwasm_std::coin; | ||
use cosmwasm_std::Binary; | ||
Check failure on line 6 in tests/src/tests/controller_tests/list_streams.rs GitHub Actions / Lints
|
||
use cw_multi_test::Executor; | ||
Check failure on line 7 in tests/src/tests/controller_tests/list_streams.rs GitHub Actions / Lints
|
||
use streamswap_types::controller::{QueryMsg, StreamsResponse}; | ||
Check failure on line 8 in tests/src/tests/controller_tests/list_streams.rs GitHub Actions / Lints
|
||
|
||
#[test] | ||
fn test_list_streams() { | ||
let Suite { | ||
mut app, | ||
test_accounts, | ||
stream_swap_code_id, | ||
stream_swap_controller_code_id, | ||
vesting_code_id, | ||
} = SuiteBuilder::default().build(); | ||
|
||
let msg = get_controller_inst_msg(stream_swap_code_id, vesting_code_id, &test_accounts); | ||
let controller_address = app | ||
.instantiate_contract( | ||
stream_swap_controller_code_id, | ||
test_accounts.admin.clone(), | ||
&msg, | ||
&[], | ||
"Controller".to_string(), | ||
None, | ||
) | ||
.unwrap(); | ||
|
||
let create_stream_msg = CreateStreamMsgBuilder::new( | ||
"stream", | ||
test_accounts.creator_1.as_ref(), | ||
coin(100, "out_denom"), | ||
"in_denom", | ||
app.block_info().time.plus_seconds(50), | ||
app.block_info().time.plus_seconds(100), | ||
app.block_info().time.plus_seconds(200), | ||
) | ||
.salt( | ||
Binary::from_base64("dGlnaHRseXB1YmxpY2h1cnJ5Y2FyZWZ1bHJ1bGVyYm93d2FpdHZhcG9ydHJ1dGhicmk") | ||
.unwrap(), | ||
) | ||
.build(); | ||
|
||
let res = app | ||
.execute_contract( | ||
test_accounts.creator_1.clone(), | ||
controller_address.clone(), | ||
&create_stream_msg, | ||
&[coin(100, "fee_denom"), coin(100, "out_denom")], | ||
) | ||
.unwrap(); | ||
let stream_addr1 = get_wasm_attribute_with_key(res, "stream_contract_addr".to_string()); | ||
|
||
let create_stream_msg = CreateStreamMsgBuilder::new( | ||
"stream2", | ||
test_accounts.creator_2.as_ref(), | ||
coin(200, "out_denom"), | ||
"in_denom", | ||
app.block_info().time.plus_seconds(50), | ||
app.block_info().time.plus_seconds(100), | ||
app.block_info().time.plus_seconds(200), | ||
) | ||
.salt( | ||
Binary::from_base64("bmVlZHNpbnRlcmVzdGtub3dudGhlbWRyYXdlc3BlY2lhbGx5d29ubm90aWNldmFsdWU") | ||
.unwrap(), | ||
) | ||
.build(); | ||
|
||
let res = app | ||
.execute_contract( | ||
test_accounts.creator_2.clone(), | ||
controller_address.clone(), | ||
&create_stream_msg, | ||
&[coin(100, "fee_denom"), coin(200, "out_denom")], | ||
) | ||
.unwrap(); | ||
let stream_addr2 = get_wasm_attribute_with_key(res, "stream_contract_addr".to_string()); | ||
|
||
let res: StreamsResponse = app | ||
.wrap() | ||
.query_wasm_smart( | ||
controller_address.clone(), | ||
&QueryMsg::ListStreams { | ||
start_after: None, | ||
limit: None, | ||
}, | ||
) | ||
.unwrap(); | ||
|
||
assert_eq!(res.streams.len(), 2); | ||
assert_eq!(res.streams[0].id, 1); | ||
assert_eq!(res.streams[0].address, stream_addr1); | ||
|
||
assert_eq!(res.streams[1].id, 2); | ||
assert_eq!(res.streams[1].address, stream_addr2); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod controller_freeze; | ||
mod instantiate; | ||
mod list_streams; | ||
mod params_update; |