ldk_node.rs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. use anyhow::Result;
  2. use cdk_integration_tests::get_mint_url_from_env;
  3. #[tokio::test]
  4. async fn test_ldk_node_mint_info() -> Result<()> {
  5. // This test just verifies that the LDK-Node mint is running and responding
  6. let mint_url = get_mint_url_from_env();
  7. // Create an HTTP client
  8. let client = reqwest::Client::new();
  9. // Make a request to the info endpoint
  10. let response = client.get(&format!("{}/v1/info", mint_url)).send().await?;
  11. // Check that we got a successful response
  12. assert_eq!(response.status(), 200);
  13. // Try to parse the response as JSON
  14. let info: serde_json::Value = response.json().await?;
  15. // Verify that we got some basic fields
  16. assert!(info.get("name").is_some());
  17. assert!(info.get("version").is_some());
  18. assert!(info.get("description").is_some());
  19. println!("LDK-Node mint info: {:?}", info);
  20. Ok(())
  21. }
  22. #[tokio::test]
  23. async fn test_ldk_node_mint_quote() -> Result<()> {
  24. // This test verifies that we can create a mint quote with the LDK-Node mint
  25. let mint_url = get_mint_url_from_env();
  26. // Create an HTTP client
  27. let client = reqwest::Client::new();
  28. // Create a mint quote request
  29. let quote_request = serde_json::json!({
  30. "amount": 1000,
  31. "unit": "sat"
  32. });
  33. // Make a request to create a mint quote
  34. let response = client
  35. .post(&format!("{}/v1/mint/quote/bolt11", mint_url))
  36. .json(&quote_request)
  37. .send()
  38. .await?;
  39. // Print the response for debugging
  40. let status = response.status();
  41. let text = response.text().await?;
  42. println!("Mint quote response status: {}", status);
  43. println!("Mint quote response body: {}", text);
  44. // For now, we'll just check that we get a response (even if it's an error)
  45. // In a real test, we'd want to verify the quote was created correctly
  46. assert!(status.is_success() || status.as_u16() < 500);
  47. Ok(())
  48. }