Skip to content

Commit

Permalink
ibc: Add functions for killing and starting relayer.
Browse files Browse the repository at this point in the history
  • Loading branch information
dowlandaiello committed Aug 14, 2024
1 parent 6272c78 commit b547c5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions examples/neutron_osmosis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ fn main() -> Result<(), Box<dyn Error>> {
.with_transfer_channels("osmosis", "neutron")
.build()?;

// Kill and restart the relayer
ctx.stop_relayer();
ctx.start_relayer();

ctx.build_tx_create_tokenfactory_token()
.with_chain_name("neutron")
.with_subdenom("bruhtoken")
Expand Down
24 changes: 23 additions & 1 deletion src/utils/setup/ibc.rs
Original file line number Diff line number Diff line change
@@ -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},
};

Expand Down Expand Up @@ -134,4 +136,24 @@ impl TestContext {

Ok(())
}

pub fn start_relayer(&mut self) {
let neutron = self.get_chain(NEUTRON_CHAIN_NAME);

reqwest::blocking::Client::default()
.post(&neutron.rb.api)
.json(&serde_json::json!({ "chain_id": NEUTRON_CHAIN_ID, "action": "start-relayer"}))
.send()
.unwrap();
}

pub fn stop_relayer(&mut self) {
let neutron = self.get_chain(NEUTRON_CHAIN_NAME);

reqwest::blocking::Client::default()
.post(&neutron.rb.api)
.json(&serde_json::json!({ "chain_id": NEUTRON_CHAIN_ID, "action": "stop-relayer"}))
.send()
.unwrap();
}
}

0 comments on commit b547c5c

Please sign in to comment.