Skip to content

Commit

Permalink
add sleep to avoid hitting docker endpoint frequently
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinHon committed Aug 31, 2023
1 parent 682d9fe commit 7e47451
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ async fn execute(
// Fail to inspect. The loop should be terminated.
return false
}
// A small delay to avoid hitting docker endpoint immediately.
tokio::time::sleep(Duration::from_millis(20)).await;
}
})
.await
Expand Down
15 changes: 11 additions & 4 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,22 @@ async fn build_contract_without_docker() {
.join("tests")
.join("contracts")
.to_path_buf();
let wasm_name = pchain_compile::Config {
let run_result = pchain_compile::Config {
source_path,
destination_path: Some(destination_path.clone()),
build_options: BuildOptions { locked: true },
docker_option: DockerOption::Dockerless,
}
.run()
.await
.unwrap();
.run()
.await;

let wasm_name = match run_result {
Ok(wasm_name) => wasm_name,
Err(e) => {
println!("{:?}", e);
panic!("Note: This test require installation of target 'wasm32-unknown-unknown'. It can be installed by 'rustup add wasm32-unknown-unknown'");
}
};

assert!(destination_path.join("Cargo.lock").exists());
let _ = std::fs::remove_file(destination_path.join(&wasm_name));
Expand Down

0 comments on commit 7e47451

Please sign in to comment.