|
| 1 | +//! Test evo node status and other node-related functionality. |
| 2 | +
|
| 3 | +use dash_sdk::platform::{types::evonode::EvoNode, FetchUnproved}; |
| 4 | +use drive_proof_verifier::types::EvonodeStatus; |
| 5 | +use http::Uri; |
| 6 | + |
| 7 | +use super::{common::setup_logs, config::Config}; |
| 8 | + |
| 9 | +/// Given some existing evonode URIs, WHEN we connect to them, THEN we get status. |
| 10 | +#[tokio::test(flavor = "multi_thread", worker_threads = 1)] |
| 11 | +async fn test_evonode_status() { |
| 12 | + setup_logs(); |
| 13 | + |
| 14 | + let cfg = Config::new(); |
| 15 | + let sdk = cfg.setup_api("test_evonode_status").await; |
| 16 | + |
| 17 | + let addresses = sdk.address_list().unwrap(); |
| 18 | + |
| 19 | + for address in addresses.addresses() { |
| 20 | + let node = EvoNode::new(address.clone()); |
| 21 | + let status = EvonodeStatus::fetch_unproved(&sdk, node) |
| 22 | + .await |
| 23 | + .expect("fetch evonode status") |
| 24 | + .expect("found evonode status"); |
| 25 | + |
| 26 | + tracing::debug!(?status, ?address, "evonode status"); |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +/// Given invalid evonode URI, when we request status, we get error. |
| 31 | +#[tokio::test(flavor = "multi_thread", worker_threads = 1)] |
| 32 | +async fn test_evonode_status_refused() { |
| 33 | + setup_logs(); |
| 34 | + |
| 35 | + let cfg = Config::new(); |
| 36 | + let sdk = cfg.setup_api("test_evonode_status_refused").await; |
| 37 | + |
| 38 | + let uri: Uri = "http://127.0.0.1:1".parse().unwrap(); |
| 39 | + |
| 40 | + let node = EvoNode::new(uri.clone().into()); |
| 41 | + let result = EvonodeStatus::fetch_unproved(&sdk, node).await; |
| 42 | + |
| 43 | + assert!(result.is_err()); |
| 44 | + |
| 45 | + tracing::debug!(?result, ?uri, "evonode status"); |
| 46 | +} |
0 commit comments