diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5b669ebc0b..a2f63deb48 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -40,6 +40,10 @@ jobs: cargo build --manifest-path=roles/Cargo.toml cargo build --manifest-path=utils/Cargo.toml + - name: Roles Integration Tests + run: | + cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture + - name: Run sv1-client-and-server example run: | cargo run --manifest-path=examples/sv1-client-and-server/Cargo.toml --bin client_and_server -- 60 diff --git a/roles/tests-integration/tests/pool_integration.rs b/roles/tests-integration/tests/pool_integration.rs new file mode 100644 index 0000000000..55aab0208b --- /dev/null +++ b/roles/tests-integration/tests/pool_integration.rs @@ -0,0 +1,36 @@ +use std::{net::SocketAddr, str::FromStr}; + +use crate::common::{get_available_port, is_port_open}; + +mod common; + +#[tokio::test] +async fn success_pool_template_provider_connection() { + assert!(common::start_template_provider_and_pool().await.is_ok()); +} + +#[tokio::test] +async fn pool_bad_coinbase_output() { + let (template_provider, template_provider_port) = common::start_template_provider().await; + let pool_port = get_available_port(); + let pool_listening_address = SocketAddr::from_str(&format!("127.0.0.1:{}", pool_port)).unwrap(); + let is_pool_port_open = is_port_open(pool_listening_address); + assert_eq!(is_pool_port_open, false); + let invalid_coinbase_output = vec![pool_sv2::mining_pool::CoinbaseOutput::new( + "P2PK".to_string(), + "04466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276728176c3c6431f8eeda4538dc37c865e2784f3a9e77d044f33e407797e1278".to_string(), + )]; + let (test_pool, _pool_port) = common::setup_poolsv2( + Some(pool_listening_address), + Some(invalid_coinbase_output), + template_provider_port, + ) + .await; + let pool = test_pool.pool.clone(); + let state = pool.state().await.safe_lock(|s| s.clone()).unwrap(); + assert_eq!(state, pool_sv2::PoolState::Initial); + assert!(pool.start().await.is_err()); + let state = pool.state().await.safe_lock(|s| s.clone()).unwrap(); + assert_eq!(state, pool_sv2::PoolState::Initial); + template_provider.stop(); +}