Skip to content

Commit

Permalink
Format and update test imports
Browse files Browse the repository at this point in the history
  • Loading branch information
adairrr committed Nov 25, 2024
1 parent 1f1043b commit 4bbd2e8
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 40 deletions.
6 changes: 5 additions & 1 deletion contracts/client/examples/local_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ fn main() -> anyhow::Result<()> {

// Get the [`Publisher`] that owns the namespace.
// If there isn't one, it creates an Account and claims the namespace.
let publisher: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;

// Ensure the current sender owns the namespace
if publisher.account().owner()? != daemon.sender().address() {
Expand Down
6 changes: 4 additions & 2 deletions contracts/client/examples/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
//! $ just publish uni-6 osmo-test-5
//! ```
use abstract_app::objects::module::ModuleVersion;
use abstract_app::objects::namespace::Namespace;
use abstract_client::{AbstractClient, Publisher};
use clap::Parser;
Expand All @@ -35,7 +34,10 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
let abstract_client: AbstractClient<Daemon> = AbstractClient::new(chain.clone())?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher_acc = abstract_client.fetch_or_build_account(app_namespace.clone(), |builder| builder.namespace(app_namespace))?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher = Publisher::new(&publisher_acc)?;

if publisher.account().owner()? != chain.sender().address() {
Expand Down
6 changes: 5 additions & 1 deletion contracts/server/examples/local_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ fn main() -> anyhow::Result<()> {

// Get the [`Publisher`] that owns the namespace.
// If there isn't one, it creates an Account and claims the namespace.
let publisher: Publisher<_> = abstract_client.publisher_builder(app_namespace).build()?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;

// Ensure the current sender owns the namespace
if publisher.account().owner()? != daemon.sender().address() {
Expand Down
5 changes: 4 additions & 1 deletion contracts/server/examples/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
let abstract_client: AbstractClient<Daemon> = AbstractClient::new(chain.clone())?;

// Get the [`Publisher`] that owns the namespace, otherwise create a new one and claim the namespace
let publisher_acc = abstract_client.fetch_or_build_account(app_namespace.clone(), |builder| builder.namespace(app_namespace))?;
let publisher_acc = abstract_client
.fetch_or_build_account(app_namespace.clone(), |builder| {
builder.namespace(app_namespace)
})?;
let publisher = Publisher::new(&publisher_acc)?;

if publisher.account().owner()? != chain.sender().address() {
Expand Down
8 changes: 3 additions & 5 deletions packages/ibcmail/src/server/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@ pub enum ServerExecuteMsg {
#[cosmwasm_schema::cw_serde]
pub enum ServerIbcMessage {
/// Route a message
RouteMessage { msg: IbcMailMessage, header: Header }
RouteMessage { msg: IbcMailMessage, header: Header },
}

/// App query messages
#[cosmwasm_schema::cw_serde]
#[derive(QueryResponses)]
#[derive(cw_orch::QueryFns)]
#[derive(QueryResponses, cw_orch::QueryFns)]
// #[cw_orch(impl_into(QueryMsg))]
pub enum ServerQueryMsg {
#[returns(ConfigResponse)]
Config {}
Config {},
}


// impl From<ServerQueryMsg> for QueryMsg {
// fn from(msg: ServerQueryMsg) -> Self {
// QueryMsg::Module(msg)
Expand Down
6 changes: 3 additions & 3 deletions tests/src/bin/approve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use abstract_interface::Abstract;
use clap::Parser;
use cw_orch::{
anyhow,
environment::TxHandler,
prelude::{*, DaemonBuilder, networks::parse_network},
prelude::{networks::parse_network, DaemonBuilder, *},
tokio::runtime::Runtime,
};

Expand All @@ -32,7 +31,8 @@ fn publish(networks: Vec<ChainInfo>) -> anyhow::Result<()> {
// Create an [`AbstractClient`]
let abs = Abstract::new(chain.clone());

abs.registry.approve_all_modules_for_namespace(app_namespace)?;
abs.registry
.approve_all_modules_for_namespace(app_namespace)?;
}
Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions tests/src/bin/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const SRC: ChainInfo = PION_1;
const DST: ChainInfo = HARPOON_4;

fn test() -> anyhow::Result<()> {
let interchain =
DaemonInterchain::new(vec![SRC, DST], &ChannelCreationValidator)?;
let interchain = DaemonInterchain::new(vec![SRC, DST], &ChannelCreationValidator)?;

let src = interchain.get_chain(SRC.chain_id)?;
let dst = interchain.get_chain(DST.chain_id)?;
Expand Down
15 changes: 7 additions & 8 deletions tests/src/bin/full_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use abstract_app::{
},
std::{
ibc_client::QueryMsgFns as IbcQueryFns,
IBC_HOST,
registry::{ExecuteMsgFns, ModuleFilter, QueryMsgFns},
IBC_HOST,
},
};
use abstract_client::AbstractClient;
Expand All @@ -21,16 +21,15 @@ use cw_orch_interchain::prelude::*;
use networks::{HARPOON_4, PION_1};

use client::ClientInterface;
use ibcmail::{client::msg::ClientExecuteMsgFns, IBCMAIL_NAMESPACE, Message};
use ibcmail::{client::msg::ClientExecuteMsgFns, Message, IBCMAIL_NAMESPACE};
use tests::TEST_NAMESPACE;

const SRC: ChainInfo = HARPOON_4;
const DST: ChainInfo = PION_1;

fn test() -> anyhow::Result<()> {
let rt = Runtime::new()?;
let interchain =
DaemonInterchain::new(vec![SRC, DST], &ChannelCreationValidator)?;
let _rt = Runtime::new()?;
let interchain = DaemonInterchain::new(vec![SRC, DST], &ChannelCreationValidator)?;

let src = interchain.get_chain(SRC.chain_id)?;
let dst = interchain.get_chain(DST.chain_id)?;
Expand Down Expand Up @@ -70,9 +69,9 @@ fn test() -> anyhow::Result<()> {

// src_acc.install_app_with_dependencies::<ClientInterface<_>>(&ClientInstantiateMsg {}, Empty {}, &[])?;
// let app = src_acc.install_app_with_dependencies::<ClientInterface<_>>(&ClientInstantiateMsg {}, Empty {},&[])?;
let app = src_acc.application::<ClientInterface<_>>()?;
let _app = src_acc.application::<ClientInterface<_>>()?;
// app.authorize_on_adapters(&[IBCMAIL_SERVER_ID])?;
let src_client = src_acc.application::<ClientInterface<_>>()?;
let _src_client = src_acc.application::<ClientInterface<_>>()?;

let dst_acc = abs_dst
.account_builder()
Expand All @@ -85,7 +84,7 @@ fn test() -> anyhow::Result<()> {
// &[],
// )?;

let app = dst_acc.application::<ClientInterface<_>>()?;
let _app = dst_acc.application::<ClientInterface<_>>()?;
// app.authorize_on_adapters(&[IBCMAIL_SERVER_ID])?;

let dst_client = dst_acc.application::<ClientInterface<_>>()?;
Expand Down
30 changes: 14 additions & 16 deletions tests/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use abstract_app::objects::{AccountId, namespace::Namespace};
use abstract_client::{AbstractClient, Application, Environment};
use abstract_app::objects::{namespace::Namespace, AccountId};
use abstract_client::{AbstractClient, Application, Publisher};
use cw_orch::{anyhow, prelude::*};
use speculoos::prelude::*;

// Use prelude to get all the necessary imports
use client::{*, contract::interface::ClientInterface, msg::ClientInstantiateMsg};
use client::{contract::interface::ClientInterface, msg::ClientInstantiateMsg, *};
use ibcmail::{
IBCMAIL_NAMESPACE, IBCMAIL_SERVER_ID, IbcMailMessage, Message, Recipient,
Sender, server::msg::ServerInstantiateMsg,
server::msg::ServerInstantiateMsg, IbcMailMessage, Message, Recipient, Sender,
IBCMAIL_NAMESPACE, IBCMAIL_SERVER_ID,
};
use server::ServerInterface;

Expand All @@ -32,14 +32,14 @@ impl<Env: CwEnv> TestEnv<Env> {
// abs_client.set_balance(sender, &coins(123, "ucosm"))?;

// Publish both the client and the server
let publisher = abs_client.publisher_builder(namespace).build()?;
let publisher_acc = abs_client
.fetch_or_build_account(namespace.clone(), |builder| builder.namespace(namespace))?;
let publisher: Publisher<_> = Publisher::new(&publisher_acc)?;
publisher.publish_app::<ClientInterface<_>>()?;
publisher
.publish_adapter::<ServerInstantiateMsg, ServerInterface<_>>(ServerInstantiateMsg {})?;

let acc = abs_client
.account_builder()
.build()?;
let acc = abs_client.account_builder().build()?;

let app = acc.install_app_with_dependencies::<ClientInterface<_>>(
&ClientInstantiateMsg {},
Expand All @@ -49,9 +49,7 @@ impl<Env: CwEnv> TestEnv<Env> {
app.authorize_on_adapters(&[IBCMAIL_SERVER_ID])?;
// acc.install_adapter::<ServerInterface<_>>(&[])?;

let acc2 = abs_client
.account_builder()
.build()?;
let acc2 = abs_client.account_builder().build()?;
let app2 = acc2.install_app_with_dependencies::<ClientInterface<_>>(
&ClientInstantiateMsg {},
Empty {},
Expand Down Expand Up @@ -86,7 +84,7 @@ fn create_test_message(from: AccountId, to: AccountId) -> IbcMailMessage {
mod receive_msg {
use speculoos::assert_that;

use ibcmail::{IBCMAIL_SERVER_ID, MessageStatus};
use ibcmail::{MessageStatus, IBCMAIL_SERVER_ID};

use super::*;

Expand Down Expand Up @@ -149,11 +147,11 @@ mod receive_msg {
mod send_msg {
use std::str::FromStr;

use abstract_app::{objects::account::AccountTrace, std::registry::ExecuteMsgFns};
use abstract_app::objects::TruncatedChainId;
use cw_orch_interchain::{InterchainEnv, MockBech32InterchainEnv};
use abstract_app::{objects::account::AccountTrace, std::registry::ExecuteMsgFns};
use cw_orch_interchain::prelude::*;

use ibcmail::{IBCMAIL_CLIENT_ID, Message, MessageStatus, server::error::ServerError};
use ibcmail::{server::error::ServerError, Message, MessageStatus, IBCMAIL_CLIENT_ID};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(test)]
mod client;

pub const TEST_NAMESPACE: &str = "ibcmail-demo";
pub const TEST_NAMESPACE: &str = "ibcmail-demo";

0 comments on commit 4bbd2e8

Please sign in to comment.