ldk_node.rs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // Make a request to the info endpoint
  8. let response = bitreq::get(format!("{}/v1/info", mint_url))
  9. .send_async()
  10. .await?;
  11. // Check that we got a successful response
  12. assert_eq!(response.status_code, 200);
  13. // Try to parse the response as JSON
  14. let info: serde_json::Value = response.json()?;
  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 a mint quote request
  27. let quote_request = serde_json::json!({
  28. "amount": 1000,
  29. "unit": "sat"
  30. });
  31. // Make a request to create a mint quote
  32. let response = bitreq::post(format!("{}/v1/mint/quote/bolt11", mint_url))
  33. .with_json(&quote_request)?
  34. .send_async()
  35. .await?;
  36. // Print the response for debugging
  37. let status = response.status_code;
  38. let text = response.as_str().unwrap_or_default();
  39. println!("Mint quote response status: {}", status);
  40. println!("Mint quote response body: {}", text);
  41. // For now, we'll just check that we get a response (even if it's an error)
  42. // In a real test, we'd want to verify the quote was created correctly
  43. assert!(status == 200 || status < 500);
  44. Ok(())
  45. }