Files
cdk/crates/cdk-integration-tests/tests/ldk_node.rs
thesimplekid 9ab86fabfe Cdk ldk node (#904)
* feat: add LDK Node Lightning backend with comprehensive integration

- Add new cdk-ldk-node crate implementing Lightning backend using LDK Node
- Extend MintPayment trait with start/stop methods for processor lifecycle management
- Add LDK Node configuration support to cdk-mintd with chain source and gossip options
- Enhance mint startup/shutdown to properly manage payment processor lifecycle

---------

Co-authored-by: Erik <78821053+swedishfrenchpress@users.noreply.github.com>
2025-08-25 22:06:00 +01:00

64 lines
1.9 KiB
Rust

use anyhow::Result;
use cdk_integration_tests::get_mint_url_from_env;
#[tokio::test]
async fn test_ldk_node_mint_info() -> Result<()> {
// This test just verifies that the LDK-Node mint is running and responding
let mint_url = get_mint_url_from_env();
// Create an HTTP client
let client = reqwest::Client::new();
// Make a request to the info endpoint
let response = client.get(&format!("{}/v1/info", mint_url)).send().await?;
// Check that we got a successful response
assert_eq!(response.status(), 200);
// Try to parse the response as JSON
let info: serde_json::Value = response.json().await?;
// Verify that we got some basic fields
assert!(info.get("name").is_some());
assert!(info.get("version").is_some());
assert!(info.get("description").is_some());
println!("LDK-Node mint info: {:?}", info);
Ok(())
}
#[tokio::test]
async fn test_ldk_node_mint_quote() -> Result<()> {
// This test verifies that we can create a mint quote with the LDK-Node mint
let mint_url = get_mint_url_from_env();
// Create an HTTP client
let client = reqwest::Client::new();
// Create a mint quote request
let quote_request = serde_json::json!({
"amount": 1000,
"unit": "sat"
});
// Make a request to create a mint quote
let response = client
.post(&format!("{}/v1/mint/quote/bolt11", mint_url))
.json(&quote_request)
.send()
.await?;
// Print the response for debugging
let status = response.status();
let text = response.text().await?;
println!("Mint quote response status: {}", status);
println!("Mint quote response body: {}", text);
// For now, we'll just check that we get a response (even if it's an error)
// In a real test, we'd want to verify the quote was created correctly
assert!(status.is_success() || status.as_u16() < 500);
Ok(())
}