From a38afa5dd2891eae1b19149119d9f8bd53de3fe5 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Mon, 18 Dec 2023 15:42:11 -0700 Subject: [PATCH] Add init function for integration tests. Can init other things too. --- .github/workflows/rust.yaml | 5 ++++- src/regtest.rs | 17 +++++++++++++++-- tests/init.rs | 11 +++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/init.rs diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 004a3c71..a1156380 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -106,8 +106,11 @@ jobs: MAIN_VAULT_ADDRESS: ${{ secrets.MAIN_VAULT_ADDRESS }} RUST_BACKTRACE: 1 + - name: RGB Test Init + run: cargo test --locked --features server --test init -- init --nocapture --test-threads 1 + - name: RGB Tests - run: cargo test --locked --features server --test rgb -- rgb --nocapture --test-threads 1 + run: cargo test --locked --features server --test rgb -- rgb --nocapture --test-threads 1 env: TEST_WALLET_SEED: ${{ secrets.TEST_WALLET_SEED }} RUST_BACKTRACE: 1 diff --git a/src/regtest.rs b/src/regtest.rs index 4edbdcd8..d5d390f3 100644 --- a/src/regtest.rs +++ b/src/regtest.rs @@ -1,6 +1,19 @@ #![cfg(not(target_arch = "wasm32"))] -use std::env; -use std::process::{Command, Stdio}; +use std::{ + env, path, + process::{Command, Stdio}, +}; + +use anyhow::Result; +use tokio::fs; + +pub async fn init_fs() -> Result<()> { + let dir = env::var("CARBONADO_DIR").unwrap_or("/tmp/bitmaskd/carbonado".to_owned()); + let dir = path::Path::new(&dir); + fs::create_dir_all(dir).await?; + + Ok(()) +} pub fn send_coins(address: &str, amount: &str) { let path = env::current_dir().expect("oh no!"); diff --git a/tests/init.rs b/tests/init.rs new file mode 100644 index 00000000..e5144cb3 --- /dev/null +++ b/tests/init.rs @@ -0,0 +1,11 @@ +#![cfg(not(target_arch = "wasm32"))] + +use anyhow::Result; +use bitmask_core::regtest::init_fs; + +#[tokio::test] +pub async fn init() -> Result<()> { + init_fs().await; + + Ok(()) +}