Skip to content
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

Migrate single part pol stride covenant tests + liquid staker contract update #310

Merged
merged 3 commits into from
Jul 23, 2024
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
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions contracts/stride-liquid-staker/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,7 @@ pub fn query(deps: QueryDeps, env: Env, msg: QueryMsg) -> NeutronResult<Binary>
)?
.0;

let autopilot = Autopilot {
autopilot: AutopilotConfig {
receiver: ica.to_string(),
stakeibc: crate::helpers::Stakeibc {
action: "LiquidStake".to_string(),
stride_address: ica,
},
},
};

let autopilot_str = to_json_string(&autopilot)?;

Ok(to_json_binary(&autopilot_str)?)
Ok(to_json_binary(&ica)?)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch here

}
QueryMsg::RemoteChainInfo {} => {
Ok(to_json_binary(&REMOTE_CHAIN_INFO.may_load(deps.storage)?)?)
Expand Down
5 changes: 5 additions & 0 deletions local-interchaintest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ polytone-note = { git = "https://github.com/DA0-DA0/polytone", rev = "a94feae" }
polytone-voice = { git = "https://github.com/DA0-DA0/polytone", rev = "a94feae" }
cw-utils = { workspace = true }
valence-covenant-two-party-pol = { workspace = true }
valence-covenant-single-party-pol = { workspace = true }
valence-covenant-swap = { workspace = true }
valence-two-party-pol-holder = { workspace = true }
valence-single-party-pol-holder = { workspace = true }
valence-astroport-liquid-pooler = { workspace = true }
valence-osmo-liquid-pooler = { workspace = true }
valence-outpost-osmo-liquid-pooler = { workspace = true }
valence-stride-liquid-staker = { workspace = true }
valence-ibc-forwarder = { workspace = true }

covenant-utils = { workspace = true }
cw20 = { workspace = true }
53 changes: 52 additions & 1 deletion local-interchaintest/src/helpers/covenant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ pub enum Covenant<'a> {
rb: &'a ChainRequestBuilder,
contract_address: &'a str,
},
SinglePartyPol {
rb: &'a ChainRequestBuilder,
contract_address: &'a str,
},
Swap {
rb: &'a ChainRequestBuilder,
contract_address: &'a str,
Expand All @@ -15,6 +19,7 @@ impl<'a> Covenant<'a> {
fn get_rb(&self) -> &ChainRequestBuilder {
match self {
Covenant::TwoPartyPol { rb, .. } => rb,
Covenant::SinglePartyPol { rb, .. } => rb,
Covenant::Swap { rb, .. } => rb,
}
}
Expand All @@ -24,6 +29,9 @@ impl<'a> Covenant<'a> {
Covenant::TwoPartyPol {
contract_address, ..
} => contract_address,
Covenant::SinglePartyPol {
contract_address, ..
} => contract_address,
Covenant::Swap {
contract_address, ..
} => contract_address,
Expand All @@ -44,6 +52,10 @@ impl<'a> Covenant<'a> {
&valence_covenant_two_party_pol::msg::QueryMsg::ClockAddress {},
)
.unwrap(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::ClockAddress {},
)
.unwrap(),
Covenant::Swap { .. } => {
&serde_json::to_string(&valence_covenant_swap::msg::QueryMsg::ClockAddress {})
.unwrap()
Expand All @@ -59,6 +71,10 @@ impl<'a> Covenant<'a> {
&valence_covenant_two_party_pol::msg::QueryMsg::HolderAddress {},
)
.unwrap(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::HolderAddress {},
)
.unwrap(),
Covenant::Swap { .. } => {
&serde_json::to_string(&valence_covenant_swap::msg::QueryMsg::HolderAddress {})
.unwrap()
Expand All @@ -74,6 +90,23 @@ impl<'a> Covenant<'a> {
&valence_covenant_two_party_pol::msg::QueryMsg::LiquidPoolerAddress {},
)
.unwrap(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::LiquidPoolerAddress {},
)
.unwrap(),
Covenant::Swap { .. } => return String::new(),
};

self.query(query_msg)
}

pub fn query_liquid_staker_address(&self) -> String {
let query_msg = match self {
Covenant::TwoPartyPol { .. } => return String::new(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::LiquidStakerAddress {},
)
.unwrap(),
Covenant::Swap { .. } => return String::new(),
};

Expand All @@ -83,6 +116,10 @@ impl<'a> Covenant<'a> {
pub fn query_splitter_address(&self) -> String {
let query_msg = match self {
Covenant::TwoPartyPol { .. } => return String::new(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::SplitterAddress {},
)
.unwrap(),
Covenant::Swap { .. } => {
&serde_json::to_string(&valence_covenant_swap::msg::QueryMsg::SplitterAddress {})
.unwrap()
Expand All @@ -98,6 +135,10 @@ impl<'a> Covenant<'a> {
&valence_covenant_two_party_pol::msg::QueryMsg::InterchainRouterAddress { party },
)
.unwrap(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::InterchainRouterAddress {},
)
.unwrap(),
Covenant::Swap { .. } => &serde_json::to_string(
&valence_covenant_swap::msg::QueryMsg::InterchainRouterAddress { party },
)
Expand All @@ -114,12 +155,17 @@ impl<'a> Covenant<'a> {
&valence_covenant_two_party_pol::msg::QueryMsg::IbcForwarderAddress { party },
)
.unwrap(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::IbcForwarderAddress {
ty: party,
},
)
.unwrap(),
Covenant::Swap { .. } => &serde_json::to_string(
&valence_covenant_swap::msg::QueryMsg::IbcForwarderAddress { party },
)
.unwrap(),
};

self.query(query_msg)
}

Expand All @@ -130,11 +176,16 @@ impl<'a> Covenant<'a> {
&valence_covenant_two_party_pol::msg::QueryMsg::PartyDepositAddress { party },
)
.unwrap(),
Covenant::SinglePartyPol { .. } => &serde_json::to_string(
&valence_covenant_single_party_pol::msg::QueryMsg::PartyDepositAddress {},
)
.unwrap(),
Covenant::Swap { .. } => &serde_json::to_string(
&valence_covenant_swap::msg::QueryMsg::PartyDepositAddress { party },
)
.unwrap(),
};

self.query(query_msg)
}
}
32 changes: 32 additions & 0 deletions local-interchaintest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
use localic_std::modules::bank::get_balance;
use localic_utils::utils::test_context::TestContext;

pub mod helpers;
pub mod tests;

pub fn send_non_native_balances(
test_ctx: &mut TestContext,
chain_name: &str,
key: &str,
source: &str,
destination: &str,
native_denom: &str,
) {
let balances = get_balance(
test_ctx
.get_request_builder()
.get_request_builder(chain_name),
source,
);
for coin in balances {
if coin.denom != native_denom {
test_ctx
.build_tx_transfer()
.with_chain_name(chain_name)
.with_amount(coin.amount.u128())
.with_recipient(destination)
.with_denom(&coin.denom)
.with_key(key)
.send()
.unwrap();
}
}
}
2 changes: 2 additions & 0 deletions local-interchaintest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::error::Error;

use local_ictest_e2e::tests::{
single_party_pol::single_party_pol_stride::test_single_party_pol_stride,
swap::token_swap::test_token_swap,
two_party_pol::{
two_party_pol_native::test_two_party_pol_native,
Expand Down Expand Up @@ -39,6 +40,7 @@ fn main() -> Result<(), Box<dyn Error>> {

test_ctx.set_up_stride_host_zone(GAIA_CHAIN_NAME);

test_single_party_pol_stride(&mut test_ctx);
test_token_swap(&mut test_ctx);
test_two_party_pol_osmo(&mut test_ctx);
test_two_party_pol_native(&mut test_ctx);
Expand Down
1 change: 1 addition & 0 deletions local-interchaintest/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod single_party_pol;
pub mod swap;
pub mod two_party_pol;
1 change: 1 addition & 0 deletions local-interchaintest/src/tests/single_party_pol/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod single_party_pol_stride;
Loading
Loading