ldk_node.rs 1.9 KB

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