Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/stream/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ pub fn query_stream(deps: Deps, _env: Env) -> StdResult<StreamResponse> {
let stream = STREAM_STATE.load(deps.storage)?;
let stream_info = STREAM_INFO.load(deps.storage)?;
let stream = StreamResponse {
name: stream_info.name,
treasury: stream_info.treasury.to_string(),
in_denom: stream.in_denom,
out_asset: stream.out_asset,
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/stream/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ pub struct ConfigResponse {
}
#[cw_serde]
pub struct StreamResponse {
/// Unique name of the stream.
pub name: String,
/// Address of the treasury where the stream earnings will be sent.
pub treasury: String,
/// URL of the stream.
Expand Down
99 changes: 99 additions & 0 deletions tests/src/tests/controller_tests/list_streams.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#![cfg(test)]
use crate::helpers::mock_messages::{get_controller_inst_msg, CreateStreamMsgBuilder};
use crate::helpers::suite::{Suite, SuiteBuilder};
use crate::helpers::utils::get_wasm_attribute_with_key;
use cosmwasm_std::coin;
use cosmwasm_std::Binary;
use cw_multi_test::Executor;
use streamswap_types::controller::{QueryMsg, StreamsResponse};

#[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);
}
1 change: 1 addition & 0 deletions tests/src/tests/controller_tests/mod.rs
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;