diff --git a/examples/neutron_osmosis.rs b/examples/neutron_osmosis.rs index 5170c69..8b8ac6a 100644 --- a/examples/neutron_osmosis.rs +++ b/examples/neutron_osmosis.rs @@ -1,5 +1,5 @@ use localic_utils::{ConfigChainBuilder, TestContextBuilder}; -use std::error::Error; +use std::{error::Error, thread, time::Duration}; const ACC_0_ADDR: &str = "osmo1hj5fveer5cjtn4wd6wstzugjfdxzl0xpwhpz63"; const NEUTRON_ACC_0_ADDR: &str = "neutron1hj5fveer5cjtn4wd6wstzugjfdxzl0xpznmsky"; @@ -18,6 +18,13 @@ fn main() -> Result<(), Box> { .with_transfer_channels("osmosis", "neutron") .build()?; + // Kill and restart the relayer + ctx.stop_relayer(); + ctx.start_relayer(); + + // Wait for the relayer to start up + thread::sleep(Duration::from_secs(10)); + ctx.build_tx_create_tokenfactory_token() .with_chain_name("neutron") .with_subdenom("bruhtoken") diff --git a/src/utils/setup/ibc.rs b/src/utils/setup/ibc.rs index 590778e..a8e9905 100644 --- a/src/utils/setup/ibc.rs +++ b/src/utils/setup/ibc.rs @@ -1,5 +1,7 @@ use super::super::{ - super::{error::Error, DEFAULT_KEY, DEFAULT_TRANSFER_PORT, NEUTRON_CHAIN_NAME}, + super::{ + error::Error, DEFAULT_KEY, DEFAULT_TRANSFER_PORT, NEUTRON_CHAIN_ID, NEUTRON_CHAIN_NAME, + }, test_context::{LocalChain, TestContext}, }; @@ -134,4 +136,32 @@ impl TestContext { Ok(()) } + + pub fn start_relayer(&mut self) { + // Any random chain will allow us to kill the relayer, + // so select any chain we can get the API URL from + let chain = self.chains.values().next().unwrap(); + + // See above. chain_id does not matter, since there is + // one relayer running + reqwest::blocking::Client::default() + .post(&chain.rb.api) + .json(&serde_json::json!({ "chain_id": NEUTRON_CHAIN_ID, "action": "start-relayer"})) + .send() + .unwrap(); + } + + pub fn stop_relayer(&mut self) { + // Any random chain will allow us to kill the relayer, + // so select any chain we can get the API URL from + let chain = self.chains.values().next().unwrap(); + + // See above. chain_id does not matter, since there is + // one relayer running + reqwest::blocking::Client::default() + .post(&chain.rb.api) + .json(&serde_json::json!({ "chain_id": NEUTRON_CHAIN_ID, "action": "stop-relayer"})) + .send() + .unwrap(); + } }