Skip to content

Commit

Permalink
Add init function for integration tests. Can init other things too.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoquick committed Dec 18, 2023
1 parent 3749290 commit a38afa5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions src/regtest.rs
Original file line number Diff line number Diff line change
@@ -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!");
Expand Down
11 changes: 11 additions & 0 deletions tests/init.rs
Original file line number Diff line number Diff line change
@@ -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;

Check failure on line 8 in tests/init.rs

View workflow job for this annotation

GitHub Actions / lint

error: unused `std::result::Result` that must be used --> tests/init.rs:8:5 | 8 | init_fs().await; | ^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled = note: `-D unused-must-use` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_must_use)]` help: use `let _ = ...` to ignore the resulting value | 8 | let _ = init_fs().await; | +++++++

Ok(())
}

0 comments on commit a38afa5

Please sign in to comment.