Skip to content

Commit

Permalink
ibc: For start/stop relayer, use whichever chain is available.
Browse files Browse the repository at this point in the history
Instead of assumming Neutron exists.
  • Loading branch information
dowlandaiello committed Aug 15, 2024
1 parent b547c5c commit 8bbe015
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion examples/neutron_osmosis.rs
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -22,6 +22,9 @@ fn main() -> Result<(), Box<dyn Error>> {
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")
Expand Down
16 changes: 12 additions & 4 deletions src/utils/setup/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,28 @@ impl TestContext {
}

pub fn start_relayer(&mut self) {
let neutron = self.get_chain(NEUTRON_CHAIN_NAME);
// 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(&neutron.rb.api)
.post(&chain.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);
// 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(&neutron.rb.api)
.post(&chain.rb.api)
.json(&serde_json::json!({ "chain_id": NEUTRON_CHAIN_ID, "action": "stop-relayer"}))
.send()
.unwrap();
Expand Down

0 comments on commit 8bbe015

Please sign in to comment.