Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions src/modules/blocktank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ mod tests {
}

Comment thread
ovitrif marked this conversation as resolved.
Resolved
#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_fetch_and_store_info() {
// Initialize in-memory database
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
Expand Down Expand Up @@ -534,6 +535,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_create_and_store_order() {
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
.await
Expand All @@ -560,6 +562,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_refresh_orders() {
// Initialize in-memory database
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
Expand Down Expand Up @@ -957,6 +960,20 @@ mod tests {
}

Comment thread
ovitrif marked this conversation as resolved.
Resolved
#[tokio::test]
async fn test_refresh_active_with_empty_db() {
let db = BlocktankDB::new(":memory:", Some("http://invalid-url"))
.await
.unwrap();

let orders = db.refresh_active_orders().await.unwrap();
assert!(orders.is_empty());

let entries = db.refresh_active_cjit_entries().await.unwrap();
assert!(entries.is_empty());
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_refresh_active_orders() {
// Initialize in-memory database
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
Expand Down Expand Up @@ -1081,6 +1098,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_get_min_zero_conf_tx_fee() {
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
.await
Expand Down Expand Up @@ -1135,6 +1153,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_estimate_order_fee() {
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
.await
Expand Down Expand Up @@ -1183,6 +1202,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_estimate_order_fee_full() {
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
.await
Expand Down Expand Up @@ -1590,6 +1610,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_cjit_entry_integration() {
// Initialize database with staging server
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
Expand Down Expand Up @@ -1690,6 +1711,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_cjit_entry_invalid_params() {
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
.await
Expand Down Expand Up @@ -1873,6 +1895,7 @@ mod tests {
}

Comment thread
ovitrif marked this conversation as resolved.
Resolved
#[tokio::test]
#[ignore = "calls live Blocktank staging"]
async fn test_refresh_active_cjit_entries() {
// Initialize database with staging server
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
Expand Down Expand Up @@ -1985,27 +2008,33 @@ mod tests {

#[tokio::test]
async fn test_regtest_mine() {
// Staging's regtest routes need this key; skip without it.
let Ok(auth) = std::env::var("BLOCKTANK_REGTEST_AUTH") else {
return;
};
Comment thread
ovitrif marked this conversation as resolved.
Resolved
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
.await
.unwrap();
// Test mining 1 block
let auth = std::env::var("BLOCKTANK_REGTEST_AUTH").ok();
let result = db.regtest_mine(Some(1), auth.as_deref()).await;
let result = db.regtest_mine(Some(1), Some(auth.as_str())).await;
assert!(result.is_ok(), "Failed to mine 1 block: {:?}", result.err());
}

#[tokio::test]
async fn test_regtest_deposit() {
// Staging's regtest routes need this key; skip without it.
let Ok(auth) = std::env::var("BLOCKTANK_REGTEST_AUTH") else {
return;
};
let db = BlocktankDB::new(":memory:", Some(STAGING_SERVER))
.await
.unwrap();
let auth = std::env::var("BLOCKTANK_REGTEST_AUTH").ok();

let test_address = "bcrt1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu";

// Test deposit with specific amount
let result = db
.regtest_deposit(test_address, Some(50000), auth.as_deref())
.regtest_deposit(test_address, Some(50000), Some(auth.as_str()))
.await;

match result {
Expand Down
Loading