Skip to content

Commit

Permalink
Add wait_for_blocks function (#10)
Browse files Browse the repository at this point in the history
* add wait_for_blocks function

* remove useless line

* undo
  • Loading branch information
keyleu authored Aug 15, 2024
1 parent 8a5849c commit 315128e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/neutron_osmosis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ fn main() -> Result<(), Box<dyn Error>> {
// Wait for the relayer to start up
thread::sleep(Duration::from_secs(10));

// Wait for some blocks
ctx.get_chain("neutron").wait_for_blocks(20);

ctx.build_tx_create_tokenfactory_token()
.with_chain_name("neutron")
.with_subdenom("bruhtoken")
Expand Down
13 changes: 12 additions & 1 deletion src/utils/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use super::super::{
};

use localic_std::{
modules::cosmwasm::CosmWasm, relayer::Channel, relayer::Relayer,
modules::cosmwasm::CosmWasm,
node::Chain,
relayer::{Channel, Relayer},
transactions::ChainRequestBuilder,
};
use std::{collections::HashMap, path::PathBuf};
Expand Down Expand Up @@ -400,6 +402,15 @@ impl LocalChain {
let id = abs_path.file_stem().unwrap().to_str().unwrap();
self.contract_codes.insert(id.to_string(), code);
}

pub fn wait_for_blocks(&self, blocks: u64) {
let chain = Chain::new(&self.rb);
let current_height = chain.get_height();

while chain.get_height() < current_height + blocks {
std::thread::sleep(std::time::Duration::from_millis(500));
}
}
}

impl TestContext {
Expand Down

0 comments on commit 315128e

Please sign in to comment.