From ee695733a0daa4f9f14028c10cb844657636ff71 Mon Sep 17 00:00:00 2001 From: jbesraa Date: Mon, 14 Oct 2024 14:49:17 +0300 Subject: [PATCH] Add `start_jds` fn to integration tests --- roles/Cargo.lock | 1 + roles/tests-integration/Cargo.toml | 1 + roles/tests-integration/tests/common/mod.rs | 38 +++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/roles/Cargo.lock b/roles/Cargo.lock index c13e140a8..fffeb5401 100644 --- a/roles/Cargo.lock +++ b/roles/Cargo.lock @@ -1304,6 +1304,7 @@ dependencies = [ "const_sv2", "flate2", "jd_client", + "jd_server", "key-utils", "minreq", "network_helpers_sv2", diff --git a/roles/tests-integration/Cargo.toml b/roles/tests-integration/Cargo.toml index 17e569be0..b77715bda 100644 --- a/roles/tests-integration/Cargo.toml +++ b/roles/tests-integration/Cargo.toml @@ -18,6 +18,7 @@ codec_sv2 = { path = "../../protocols/v2/codec-sv2", features = ["noise_sv2"] } const_sv2 = { path = "../../protocols/v2/const-sv2" } flate2 = "1.0.32" jd_client = { path = "../jd-client" } +jd_server = { path = "../jd-server" } key-utils = { path = "../../utils/key-utils" } minreq = { version = "2.12.0", features = ["https"] } once_cell = "1.19.0" diff --git a/roles/tests-integration/tests/common/mod.rs b/roles/tests-integration/tests/common/mod.rs index 653c99053..a3e741cfd 100644 --- a/roles/tests-integration/tests/common/mod.rs +++ b/roles/tests-integration/tests/common/mod.rs @@ -342,3 +342,41 @@ pub async fn start_jdc( tokio::time::sleep(std::time::Duration::from_secs(2)).await; jdc_address } + +pub async fn start_jds(tp_address: SocketAddr) -> SocketAddr { + use jd_server::{CoinbaseOutput, Configuration, CoreRpc, JobDeclaratorServer}; + let authority_public_key = Secp256k1PublicKey::try_from( + "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72".to_string(), + ) + .unwrap(); + let authority_secret_key = Secp256k1SecretKey::try_from( + "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n".to_string(), + ) + .unwrap(); + let listen_jd_address = get_available_address(); + let cert_validity_sec = 3600; + let coinbase_outputs = vec![CoinbaseOutput::new( + "P2WPKH".to_string(), + "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075".to_string(), + )]; + let core_rpc = CoreRpc::new( + tp_address.ip().to_string(), + tp_address.port(), + "tp_username".to_string(), + "tp_password".to_string(), + ); + let config = Configuration::new( + listen_jd_address.to_string(), + authority_public_key, + authority_secret_key, + cert_validity_sec, + coinbase_outputs, + core_rpc, + std::time::Duration::from_secs(1), + ); + tokio::spawn(async move { + JobDeclaratorServer::new(config).start().await; + }); + tokio::time::sleep(std::time::Duration::from_secs(2)).await; + listen_jd_address +}