Skip to content

Commit

Permalink
avoid /tmp dir on Integration Tests..
Browse files Browse the repository at this point in the history
using /tmp is leading to undeterministic behavior on Github CI
  • Loading branch information
plebhash committed Jan 21, 2025
1 parent 6135ef2 commit d6d5525
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions roles/tests-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ $ git clone [email protected]:stratum-mining/stratum.git
$ cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture
```

Note: during the execution of the tests, a new directory called `template-provider` is created.
This directory holds the executable for Template Provider node, as well as the different data
directories created for each execution.

## License
MIT OR Apache-2.0
9 changes: 5 additions & 4 deletions roles/tests-integration/lib/template_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ pub struct TemplateProvider {

impl TemplateProvider {
pub fn start(port: u16, sv2_interval: u32) -> Self {
let temp_dir = PathBuf::from("/tmp/.template-provider");
let current_dir: PathBuf = std::env::current_dir().expect("failed to read current dir");
let tp_dir = current_dir.join("template-provider");
let mut conf = Conf::default();
let staticdir = format!(".bitcoin-{}", port);
conf.staticdir = Some(temp_dir.join(staticdir));
conf.staticdir = Some(tp_dir.join(staticdir));
let port_arg = format!("-sv2port={}", port);
let sv2_interval_arg = format!("-sv2interval={}", sv2_interval);
conf.args.extend(vec![
Expand All @@ -88,7 +89,7 @@ impl TemplateProvider {
let os = env::consts::OS;
let arch = env::consts::ARCH;
let download_filename = get_bitcoind_filename(os, arch);
let bitcoin_exe_home = temp_dir
let bitcoin_exe_home = tp_dir
.join(format!("bitcoin-sv2-tp-{}", VERSION_TP))
.join("bin");

Expand All @@ -112,7 +113,7 @@ impl TemplateProvider {
create_dir_all(parent).unwrap();
}

unpack_tarball(&tarball_bytes, &temp_dir);
unpack_tarball(&tarball_bytes, &tp_dir);

if os == "macos" {
let bitcoind_binary = bitcoin_exe_home.join("bitcoind");
Expand Down

0 comments on commit d6d5525

Please sign in to comment.