From bdc3577fc7ecae0bb4b45969ffbad9e13efc1e7f Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Fri, 29 Aug 2025 19:55:20 +0530 Subject: [PATCH 01/13] test: provider state is added for getdevice model test --- .../src/tests/contracts/thunder_device_info_pacts.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index c86815340..79a6f14e3 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -120,6 +120,7 @@ async fn test_device_get_model() { pact_builder_async .synchronous_message_interaction("A request to get the device model", |mut i| async move { + i.given("System Version info is set"); i.contents_from(get_pact!( "org.rdk.System.1.getSystemVersions", ContractResult { result } From 5a376904337600bc053a8dd56dee81cbe4053394 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Mon, 1 Sep 2025 12:41:46 +0530 Subject: [PATCH 02/13] test: added controller.status with no call sign --- .../contracts/thunder_controller_pacts.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs index ca7828d3d..2bf08af9a 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs @@ -56,6 +56,42 @@ async fn test_register_state_change_event() { .await; } +//added to avoid RESPONSE: {"jsonrpc":"2.0","error":{"code":-32600,"message":"Cannot find a matching response for the received request","data":""}} +#[tokio::test(flavor = "multi_thread")] +#[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] +async fn test_controller_status_no_callsign() { + mock_websocket_server!( + builder, + server, + server_url, + "controller_status_no_callsign", + json!({ + "pact:content-type": "application/json", + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 3)", "method": "Controller.1.status"}, + "requestMetadata": { + "path": "/jsonrpc" + }, + "response": [{ + "jsonrpc": "matching(type, '2.0')", + "id": "matching(integer, 3)", + "result": [{ + "state": "activated" + }] + }] + }) + ); + + send_thunder_call_message!( + server_url.to_string(), + json!({ + "jsonrpc": "2.0", + "id": 3, + "method": "Controller.1.status" + }) + ) + .await; +} + #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] async fn test_device_info_plugin_status() { From 5073ee88ab898d82c53ed35b36bac01c36de2be7 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Tue, 2 Sep 2025 12:35:04 +0530 Subject: [PATCH 03/13] chore: added some printlogs for get device model test --- .../tests/contracts/thunder_device_info_pacts.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index 92972cbe5..8df70c782 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -92,10 +92,12 @@ async fn test_device_get_info_mac_address() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] async fn test_device_get_model() { + println!("Starting test_device_get_model..."); let mut pact_builder_async = get_pact_builder_async_obj().await; let mut result = HashMap::new(); + println!("Preparing expected result matchers..."); result.insert( "stbVersion".into(), ContractMatcher::MatchRegex( @@ -118,6 +120,7 @@ async fn test_device_get_model() { ); result.insert("success".into(), ContractMatcher::MatchBool(true)); + println!("Setting up Pact interaction..."); pact_builder_async .synchronous_message_interaction("A request to get the device model", |mut i| async move { i.given("System Version info is set"); @@ -131,14 +134,17 @@ async fn test_device_get_model() { }) .await; + println!("Starting Pact mock server..."); let mock_server = pact_builder_async .start_mock_server_async(Some("websockets/transport/websockets")) .await; + let url = url::Url::parse(mock_server.path("/jsonrpc").as_str()) + .unwrap() + .to_string(); + println!("Sending Thunder call message to: {}", url); send_thunder_call_message!( - url::Url::parse(mock_server.path("/jsonrpc").as_str()) - .unwrap() - .to_string(), + url, json!({ "jsonrpc": "2.0", "id": 42, @@ -146,6 +152,7 @@ async fn test_device_get_model() { }) ) .await; + println!("test_device_get_model completed."); } #[tokio::test(flavor = "multi_thread")] From 14f16ba46d5b7ecb00d9c851b3c8ae8bb8af3a50 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Tue, 2 Sep 2025 15:07:51 +0530 Subject: [PATCH 04/13] chore: modified the test ids of thunder_controller_pacts.rs file tests --- .../contracts/thunder_controller_pacts.rs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs index 2bf08af9a..3f3b96265 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs @@ -67,13 +67,13 @@ async fn test_controller_status_no_callsign() { "controller_status_no_callsign", json!({ "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 3)", "method": "Controller.1.status"}, + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status"}, "requestMetadata": { "path": "/jsonrpc" }, "response": [{ "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 3)", + "id": "matching(integer, 0)", "result": [{ "state": "activated" }] @@ -102,13 +102,13 @@ async fn test_device_info_plugin_status() { "device_info_plugin_status", json!({ "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 1)", "method": "Controller.1.status@DeviceInfo"}, + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status@DeviceInfo"}, "requestMetadata": { "path": "/jsonrpc" }, "response": [{ "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 1)", + "id": "matching(integer, 0)", "result": [{ "callsign": "matching(type, 'string')", "locator": "matching(type, 'string')", @@ -185,13 +185,13 @@ async fn test_display_settings_plugin_status() { "display_settings_plugin_status", json!({ "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 3)", "method": "Controller.1.status@org.rdk.DisplaySettings"}, + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status@org.rdk.DisplaySettings"}, "requestMetadata": { "path": "/jsonrpc" }, "response": [{ "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 3)", + "id": "matching(integer, 0)", "result": [{ "callsign": "matching(type, 'string')", "locator": "matching(type, 'string')", @@ -267,13 +267,13 @@ async fn test_status_org_rdk_system() { "status_org_rdk_system", json!({ "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 5)", "method": "Controller.1.status@org.rdk.System"}, + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status@org.rdk.System"}, "requestMetadata": { "path": "/jsonrpc" }, "response": [{ "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 5)", + "id": "matching(integer, 0)", "result": [{ "callsign": "matching(type, 'string')", "locator": "matching(type, 'string')", @@ -349,13 +349,13 @@ async fn test_status_org_rdk_hdcp_profile() { "status_org_rdk_hdcp_profile", json!({ "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 7)", "method": "Controller.1.status@org.rdk.HdcpProfile"}, + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status@org.rdk.HdcpProfile"}, "requestMetadata": { "path": "/jsonrpc" }, "response": [{ "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 7)", + "id": "matching(integer, 0)", "result": [{ "callsign": "matching(type, 'string')", "locator": "matching(type, 'string')", @@ -431,13 +431,13 @@ async fn test_status_org_rdk_telemetry() { "status_org_rdk_telemetry", json!({ "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 9)", "method": "Controller.1.status@org.rdk.Telemetry"}, + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status@org.rdk.Telemetry"}, "requestMetadata": { "path": "/jsonrpc" }, "response": [{ "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 9)", + "id": "matching(integer, 0)", "result": [{ "callsign": "matching(type, 'string')", "locator": "matching(type, 'string')", From db63ac4433eb6cf9d31e2db2324d64d7e4b165eb Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Wed, 3 Sep 2025 22:42:37 +0530 Subject: [PATCH 05/13] chore: cleanup done --- .../contracts/thunder_controller_pacts.rs | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs index 3f3b96265..189db056b 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_controller_pacts.rs @@ -56,41 +56,41 @@ async fn test_register_state_change_event() { .await; } -//added to avoid RESPONSE: {"jsonrpc":"2.0","error":{"code":-32600,"message":"Cannot find a matching response for the received request","data":""}} -#[tokio::test(flavor = "multi_thread")] -#[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] -async fn test_controller_status_no_callsign() { - mock_websocket_server!( - builder, - server, - server_url, - "controller_status_no_callsign", - json!({ - "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status"}, - "requestMetadata": { - "path": "/jsonrpc" - }, - "response": [{ - "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 0)", - "result": [{ - "state": "activated" - }] - }] - }) - ); +// //added to avoid RESPONSE: {"jsonrpc":"2.0","error":{"code":-32600,"message":"Cannot find a matching response for the received request","data":""}} +// #[tokio::test(flavor = "multi_thread")] +// #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] +// async fn test_controller_status_no_callsign() { +// mock_websocket_server!( +// builder, +// server, +// server_url, +// "controller_status_no_callsign", +// json!({ +// "pact:content-type": "application/json", +// "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "Controller.1.status"}, +// "requestMetadata": { +// "path": "/jsonrpc" +// }, +// "response": [{ +// "jsonrpc": "matching(type, '2.0')", +// "id": "matching(integer, 0)", +// "result": [{ +// "state": "activated" +// }] +// }] +// }) +// ); - send_thunder_call_message!( - server_url.to_string(), - json!({ - "jsonrpc": "2.0", - "id": 3, - "method": "Controller.1.status" - }) - ) - .await; -} +// send_thunder_call_message!( +// server_url.to_string(), +// json!({ +// "jsonrpc": "2.0", +// "id": 3, +// "method": "Controller.1.status" +// }) +// ) +// .await; +// } #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] From 7d155ff6e4c51d95b98002c5bf73bcf59206ad8c Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Fri, 5 Sep 2025 16:12:23 +0530 Subject: [PATCH 06/13] chore: added some logs --- .../src/processors/thunder_device_info.rs | 6 ++++ .../contracts/thunder_device_info_pacts.rs | 32 +++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/device/thunder_ripple_sdk/src/processors/thunder_device_info.rs b/device/thunder_ripple_sdk/src/processors/thunder_device_info.rs index 7092f3692..efe480947 100644 --- a/device/thunder_ripple_sdk/src/processors/thunder_device_info.rs +++ b/device/thunder_ripple_sdk/src/processors/thunder_device_info.rs @@ -295,6 +295,7 @@ impl ThunderDeviceInfoRequestProcessor { } async fn model(state: CachedState, req: ExtnMessage) -> bool { + ripple_sdk::log::info!("@@@NNA...Entered ThunderDeviceInfoRequestProcessor::model"); let response = Self::get_model(&state).await; Self::respond(state.get_client(), req, ExtnResponse::String(response)) .await @@ -942,6 +943,11 @@ impl ExtnRequestProcessor for ThunderDeviceInfoRequestProcessor { msg: ExtnMessage, extracted_message: Self::VALUE, ) -> bool { + // Debug log: print contract name for incoming request + ripple_sdk::log::info!( + "@@@NNA...Incoming DeviceInfoRequest: {:?}", + extracted_message + ); match extracted_message { DeviceInfoRequest::Model => Self::model(state.clone(), msg).await, DeviceInfoRequest::Audio => Self::audio(state.clone(), msg).await, diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index 8df70c782..7e52db035 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -43,10 +43,13 @@ use tokio::time::{timeout, Duration}; #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] async fn test_device_get_info_mac_address() { // Define Pact request and response - Start + println!("[TEST] Starting test_device_get_info_mac_address"); let mut pact_builder_async = get_pact_builder_async_obj().await; + println!("[TEST] Pact builder initialized"); pact_builder_async .synchronous_message_interaction("A request to get the device info", |mut i| async move { + println!("[TEST] Defining synchronous message interaction for device info"); i.contents_from(json!({ "pact:content-type": "application/json", "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "org.rdk.System.1.getDeviceInfo", "params": {"params": ["estb_mac"]}}, @@ -62,16 +65,23 @@ async fn test_device_get_info_mac_address() { } }] })).await; + println!("[TEST] Interaction contents defined"); i.test_name("get_device_info_mac_address"); + println!("[TEST] Test name set: get_device_info_mac_address"); i }).await; // Define Pact request and response - End // Initialize mock server + println!("[TEST] Starting mock server for device info"); let mock_server = pact_builder_async .start_mock_server_async(Some("websockets/transport/websockets")) .await; + println!( + "[TEST] Mock server started at: {}", + mock_server.path("/jsonrpc") + ); send_thunder_call_message!( url::Url::parse(mock_server.path("/jsonrpc").as_str()) @@ -87,17 +97,19 @@ async fn test_device_get_info_mac_address() { }) ) .await; + println!("[TEST] Thunder call message sent for device info"); } #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] async fn test_device_get_model() { - println!("Starting test_device_get_model..."); + println!("@@@NNA Starting test_device_get_model"); let mut pact_builder_async = get_pact_builder_async_obj().await; + println!("@@@NNA Pact builder initialized"); let mut result = HashMap::new(); - println!("Preparing expected result matchers..."); + println!("@@@NNA Preparing expected result matchers..."); result.insert( "stbVersion".into(), ContractMatcher::MatchRegex( @@ -120,29 +132,36 @@ async fn test_device_get_model() { ); result.insert("success".into(), ContractMatcher::MatchBool(true)); - println!("Setting up Pact interaction..."); + println!("@@@NNA Setting up Pact interaction..."); pact_builder_async .synchronous_message_interaction("A request to get the device model", |mut i| async move { + println!("@@@NNA Defining synchronous message interaction for device model"); i.given("System Version info is set"); i.contents_from(get_pact!( "org.rdk.System.1.getSystemVersions", ContractResult { result } )) .await; + println!("@@@NNA Interaction contents defined"); i.test_name("get_device_model"); + println!("@@@NNA Test name set: get_device_model"); i }) .await; - println!("Starting Pact mock server..."); + println!("@@@NNA Starting Pact mock server..."); let mock_server = pact_builder_async .start_mock_server_async(Some("websockets/transport/websockets")) .await; + println!( + "@@@NNA Mock server started at: {}", + mock_server.path("/jsonrpc") + ); let url = url::Url::parse(mock_server.path("/jsonrpc").as_str()) .unwrap() .to_string(); - println!("Sending Thunder call message to: {}", url); + println!("@@@NNA Sending Thunder call message to: {}", url); send_thunder_call_message!( url, json!({ @@ -152,7 +171,8 @@ async fn test_device_get_model() { }) ) .await; - println!("test_device_get_model completed."); + println!("@@@NNA Thunder call message sent for device model"); + println!("@@@NNA test_device_get_model completed."); } #[tokio::test(flavor = "multi_thread")] From 6f29dcdaf2550e8b0e8bca7c6354456edd68600a Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Mon, 8 Sep 2025 15:15:44 +0530 Subject: [PATCH 07/13] test: device.model contract test changed. --- .../contracts/thunder_device_info_pacts.rs | 124 ++++++++++++++---- 1 file changed, 95 insertions(+), 29 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index 7e52db035..fd2e9b54d 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -100,6 +100,81 @@ async fn test_device_get_info_mac_address() { println!("[TEST] Thunder call message sent for device info"); } +// #[tokio::test(flavor = "multi_thread")] +// #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] +// async fn test_device_get_model() { +// println!("@@@NNA Starting test_device_get_model"); +// let mut pact_builder_async = get_pact_builder_async_obj().await; +// println!("@@@NNA Pact builder initialized"); + +// let mut result = HashMap::new(); + +// println!("@@@NNA Preparing expected result matchers..."); +// result.insert( +// "stbVersion".into(), +// ContractMatcher::MatchRegex( +// r"^[A-Z0-9]+_VBN_[A-Za-z0-9]+_sprint_\d{14}sdy(_[A-Z0-9_]+)*$".into(), +// "AX061AEI_VBN_1911_sprint_20200109040424sdy".into(), +// ), +// ); + +// result.insert( +// "receiverVersion".into(), +// ContractMatcher::MatchRegex(r"^\d+\.\d+\.\d+\.\d+$".into(), "3.14.0.0".into()), +// ); + +// result.insert( +// "stbTimestamp".into(), +// ContractMatcher::MatchRegex( +// r"^\w{3} \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z ]*UTC$".into(), +// "Thu 09 Jan 2020 04:04:24 AP UTC".into(), +// ), +// ); +// result.insert("success".into(), ContractMatcher::MatchBool(true)); + +// println!("@@@NNA Setting up Pact interaction..."); +// pact_builder_async +// .synchronous_message_interaction("A request to get the device model", |mut i| async move { +// println!("@@@NNA Defining synchronous message interaction for device model"); +// i.given("System Version info is set"); +// i.contents_from(get_pact!( +// "org.rdk.System.1.getSystemVersions", +// ContractResult { result } +// )) +// .await; +// println!("@@@NNA Interaction contents defined"); +// i.test_name("get_device_model"); +// println!("@@@NNA Test name set: get_device_model"); +// i +// }) +// .await; + +// println!("@@@NNA Starting Pact mock server..."); +// let mock_server = pact_builder_async +// .start_mock_server_async(Some("websockets/transport/websockets")) +// .await; +// println!( +// "@@@NNA Mock server started at: {}", +// mock_server.path("/jsonrpc") +// ); + +// let url = url::Url::parse(mock_server.path("/jsonrpc").as_str()) +// .unwrap() +// .to_string(); +// println!("@@@NNA Sending Thunder call message to: {}", url); +// send_thunder_call_message!( +// url, +// json!({ +// "jsonrpc": "2.0", +// "id": 42, +// "method": "org.rdk.System.1.getSystemVersions" +// }) +// ) +// .await; +// println!("@@@NNA Thunder call message sent for device model"); +// println!("@@@NNA test_device_get_model completed."); +// } + #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] async fn test_device_get_model() { @@ -107,40 +182,31 @@ async fn test_device_get_model() { let mut pact_builder_async = get_pact_builder_async_obj().await; println!("@@@NNA Pact builder initialized"); - let mut result = HashMap::new(); - - println!("@@@NNA Preparing expected result matchers..."); - result.insert( - "stbVersion".into(), - ContractMatcher::MatchRegex( - r"^[A-Z0-9]+_VBN_[A-Za-z0-9]+_sprint_\d{14}sdy(_[A-Z0-9_]+)*$".into(), - "AX061AEI_VBN_1911_sprint_20200109040424sdy".into(), - ), - ); - - result.insert( - "receiverVersion".into(), - ContractMatcher::MatchRegex(r"^\d+\.\d+\.\d+\.\d+$".into(), "3.14.0.0".into()), - ); - - result.insert( - "stbTimestamp".into(), - ContractMatcher::MatchRegex( - r"^\w{3} \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z ]*UTC$".into(), - "Thu 09 Jan 2020 04:04:24 AP UTC".into(), - ), - ); - result.insert("success".into(), ContractMatcher::MatchBool(true)); + println!("@@@NNA Starting test_device_get_model"); + let mut pact_builder_async = get_pact_builder_async_obj().await; + println!("@@@NNA Pact builder initialized"); - println!("@@@NNA Setting up Pact interaction..."); + println!("@@@NNA Setting up Pact interaction for string result..."); pact_builder_async .synchronous_message_interaction("A request to get the device model", |mut i| async move { println!("@@@NNA Defining synchronous message interaction for device model"); i.given("System Version info is set"); - i.contents_from(get_pact!( - "org.rdk.System.1.getSystemVersions", - ContractResult { result } - )) + i.contents_from(json!({ + "pact:content-type": "application/json", + "request": { + "jsonrpc": "matching(type, '2.0')", + "id": "matching(integer, 0)", + "method": "org.rdk.System.1.getSystemVersions" + }, + "requestMetadata": { + "path": "/jsonrpc" + }, + "response": [{ + "jsonrpc": "matching(type, '2.0')", + "id": "matching(integer, 0)", + "result": "matching(type, 'AX061AEI')" + }] + })) .await; println!("@@@NNA Interaction contents defined"); i.test_name("get_device_model"); From 9235d9c700f3956deb79f66942dda7506a5d5026 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Mon, 8 Sep 2025 16:02:39 +0530 Subject: [PATCH 08/13] test: get_device_model contract test modified --- .../contracts/thunder_device_info_pacts.rs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index fd2e9b54d..0485f805a 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -178,18 +178,11 @@ async fn test_device_get_info_mac_address() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] async fn test_device_get_model() { - println!("@@@NNA Starting test_device_get_model"); + // Start test: get_device_model let mut pact_builder_async = get_pact_builder_async_obj().await; - println!("@@@NNA Pact builder initialized"); - println!("@@@NNA Starting test_device_get_model"); - let mut pact_builder_async = get_pact_builder_async_obj().await; - println!("@@@NNA Pact builder initialized"); - - println!("@@@NNA Setting up Pact interaction for string result..."); pact_builder_async .synchronous_message_interaction("A request to get the device model", |mut i| async move { - println!("@@@NNA Defining synchronous message interaction for device model"); i.given("System Version info is set"); i.contents_from(json!({ "pact:content-type": "application/json", @@ -208,26 +201,18 @@ async fn test_device_get_model() { }] })) .await; - println!("@@@NNA Interaction contents defined"); i.test_name("get_device_model"); - println!("@@@NNA Test name set: get_device_model"); i }) .await; - println!("@@@NNA Starting Pact mock server..."); let mock_server = pact_builder_async .start_mock_server_async(Some("websockets/transport/websockets")) .await; - println!( - "@@@NNA Mock server started at: {}", - mock_server.path("/jsonrpc") - ); let url = url::Url::parse(mock_server.path("/jsonrpc").as_str()) .unwrap() .to_string(); - println!("@@@NNA Sending Thunder call message to: {}", url); send_thunder_call_message!( url, json!({ @@ -237,8 +222,6 @@ async fn test_device_get_model() { }) ) .await; - println!("@@@NNA Thunder call message sent for device model"); - println!("@@@NNA test_device_get_model completed."); } #[tokio::test(flavor = "multi_thread")] From 4e3ceea8b8d15b86d59cfdad7247c598c788d822 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Mon, 8 Sep 2025 17:07:22 +0530 Subject: [PATCH 09/13] test: contract test modified --- .../contracts/thunder_device_info_pacts.rs | 75 ++++++++++--------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index 0485f805a..970e16030 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -183,7 +183,7 @@ async fn test_device_get_model() { pact_builder_async .synchronous_message_interaction("A request to get the device model", |mut i| async move { - i.given("System Version info is set"); + i.given("websocket connection has been established"); i.contents_from(json!({ "pact:content-type": "application/json", "request": { @@ -217,8 +217,8 @@ async fn test_device_get_model() { url, json!({ "jsonrpc": "2.0", - "id": 42, - "method": "org.rdk.System.1.getSystemVersions" + "id": 0, + "method": "Device.model" }) ) .await; @@ -230,44 +230,47 @@ async fn test_device_get_interfaces_wifi() { let mut pact_builder_async = get_pact_builder_async_obj().await; pact_builder_async - .synchronous_message_interaction("A request to get the device wifi interface", |mut i| async move { - i.contents_from(json!({ - "pact:content-type": "application/json", - "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "org.rdk.Network.1.getInterfaces"}, - "requestMetadata": { - "path": "/jsonrpc" - }, - "response": [{ - "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 0)", - "result": { - "interfaces": [ - { - "interface": "matching(regex, '(WIFI|ETHERNET)', 'WIFI')", - "macAddress": "matching(regex, '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$', 'AA:AA:AA:AA:AA:AA')", - "enabled": "matching(boolean, true)", - "connected": "matching(boolean, true)" - }, - { - "interface": "matching(regex, '(WIFI|ETHERNET)', 'ETHERNET')", - "macAddress": "matching(regex, '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$', 'AA:AA:AA:AA:AA:AA')", - "enabled": "matching(boolean, true)", - "connected": "matching(boolean, false)" - } - ], - "success": true - } - }] - })).await; - i.test_name("get_device_interfaces_wifi"); - - i - }).await; + .synchronous_message_interaction("A request to get the device model", |mut i| async move { + i.given("Device model is set"); + i.contents_from(json!({ + "pact:content-type": "application/json", + "request": { + "jsonrpc": "2.0", + "id": 0, + "method": "Device.model" + }, + "requestMetadata": { + "path": "/jsonrpc" + }, + "response": [{ + "jsonrpc": "2.0", + "id": 0, + "result": "xi7" + }] + })) + .await; + i.test_name("get_device_model"); + i + }) + .await; let mock_server = pact_builder_async .start_mock_server_async(Some("websockets/transport/websockets")) .await; + let url = url::Url::parse(mock_server.path("/jsonrpc").as_str()) + .unwrap() + .to_string(); + send_thunder_call_message!( + url, + json!({ + "jsonrpc": "2.0", + "id": 0, + "method": "Device.model" + }) + ) + .await; + send_thunder_call_message!( url::Url::parse(mock_server.path("/jsonrpc").as_str()) .unwrap() From 49946f11dc849f00ba0a621058eba7672b614237 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Mon, 8 Sep 2025 18:34:51 +0530 Subject: [PATCH 10/13] test: contract tests modified --- .../contracts/thunder_device_info_pacts.rs | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index 970e16030..95bd21a72 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -177,31 +177,39 @@ async fn test_device_get_info_mac_address() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] -async fn test_device_get_model() { - // Start test: get_device_model +async fn test_device_get_system_verisons() { let mut pact_builder_async = get_pact_builder_async_obj().await; + let mut result = HashMap::new(); + result.insert( + "stbVersion".into(), + ContractMatcher::MatchRegex( + r"^[A-Z0-9]+_VBN_[A-Za-z0-9]+_sprint_\d{14}sdy(_[A-Z0-9_]+)*$".into(), + "AX061AEI_VBN_1911_sprint_20200109040424sdy".into(), + ), + ); + result.insert( + "receiverVersion".into(), + ContractMatcher::MatchRegex(r"^\d+\.\d+\.\d+\.\d+$".into(), "3.14.0.0".into()), + ); + result.insert( + "stbTimestamp".into(), + ContractMatcher::MatchRegex( + r"^\w{3} \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z ]*UTC$".into(), + "Thu 09 Jan 2020 04:04:24 AP UTC".into(), + ), + ); + result.insert("success".into(), ContractMatcher::MatchBool(true)); + pact_builder_async - .synchronous_message_interaction("A request to get the device model", |mut i| async move { - i.given("websocket connection has been established"); - i.contents_from(json!({ - "pact:content-type": "application/json", - "request": { - "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 0)", - "method": "org.rdk.System.1.getSystemVersions" - }, - "requestMetadata": { - "path": "/jsonrpc" - }, - "response": [{ - "jsonrpc": "matching(type, '2.0')", - "id": "matching(integer, 0)", - "result": "matching(type, 'AX061AEI')" - }] - })) + .synchronous_message_interaction("A request to get system versions", |mut i| async move { + i.given("System Version info is set"); + i.contents_from(get_pact!( + "org.rdk.System.1.getSystemVersions", + ContractResult { result } + )) .await; - i.test_name("get_device_model"); + i.test_name("get_system_versions"); i }) .await; @@ -217,8 +225,8 @@ async fn test_device_get_model() { url, json!({ "jsonrpc": "2.0", - "id": 0, - "method": "Device.model" + "id": 42, + "method": "org.rdk.System.1.getSystemVersions" }) ) .await; @@ -226,7 +234,7 @@ async fn test_device_get_model() { #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] -async fn test_device_get_interfaces_wifi() { +async fn test_device_get_model() { let mut pact_builder_async = get_pact_builder_async_obj().await; pact_builder_async @@ -278,7 +286,7 @@ async fn test_device_get_interfaces_wifi() { json!({ "jsonrpc": "2.0", "id": 0, - "method": "org.rdk.Network.1.getInterfaces" + "method": "device.model" }) ) .await; From e29c4a900387a02aea55b62da5c3bf1690c158d2 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Mon, 8 Sep 2025 19:10:02 +0530 Subject: [PATCH 11/13] chore: commented out the get device model contract test --- .../contracts/thunder_device_info_pacts.rs | 110 +++++++++--------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index 95bd21a72..3cc989017 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -232,65 +232,65 @@ async fn test_device_get_system_verisons() { .await; } -#[tokio::test(flavor = "multi_thread")] -#[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] -async fn test_device_get_model() { - let mut pact_builder_async = get_pact_builder_async_obj().await; +// #[tokio::test(flavor = "multi_thread")] +// #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] +// async fn test_device_get_model() { +// let mut pact_builder_async = get_pact_builder_async_obj().await; - pact_builder_async - .synchronous_message_interaction("A request to get the device model", |mut i| async move { - i.given("Device model is set"); - i.contents_from(json!({ - "pact:content-type": "application/json", - "request": { - "jsonrpc": "2.0", - "id": 0, - "method": "Device.model" - }, - "requestMetadata": { - "path": "/jsonrpc" - }, - "response": [{ - "jsonrpc": "2.0", - "id": 0, - "result": "xi7" - }] - })) - .await; - i.test_name("get_device_model"); - i - }) - .await; +// pact_builder_async +// .synchronous_message_interaction("A request to get the device model", |mut i| async move { +// i.given("Device model is set"); +// i.contents_from(json!({ +// "pact:content-type": "application/json", +// "request": { +// "jsonrpc": "2.0", +// "id": 0, +// "method": "Device.model" +// }, +// "requestMetadata": { +// "path": "/jsonrpc" +// }, +// "response": [{ +// "jsonrpc": "2.0", +// "id": 0, +// "result": "xi7" +// }] +// })) +// .await; +// i.test_name("get_device_model"); +// i +// }) +// .await; - let mock_server = pact_builder_async - .start_mock_server_async(Some("websockets/transport/websockets")) - .await; +// let mock_server = pact_builder_async +// .start_mock_server_async(Some("websockets/transport/websockets")) +// .await; - let url = url::Url::parse(mock_server.path("/jsonrpc").as_str()) - .unwrap() - .to_string(); - send_thunder_call_message!( - url, - json!({ - "jsonrpc": "2.0", - "id": 0, - "method": "Device.model" - }) - ) - .await; +// let url = url::Url::parse(mock_server.path("/jsonrpc").as_str()) +// .unwrap() +// .to_string(); +// send_thunder_call_message!( +// url, +// json!({ +// "jsonrpc": "2.0", +// "id": 0, +// "method": "Device.model" +// }) +// ) +// .await; - send_thunder_call_message!( - url::Url::parse(mock_server.path("/jsonrpc").as_str()) - .unwrap() - .to_string(), - json!({ - "jsonrpc": "2.0", - "id": 0, - "method": "device.model" - }) - ) - .await; -} +// send_thunder_call_message!( +// url::Url::parse(mock_server.path("/jsonrpc").as_str()) +// .unwrap() +// .to_string(), +// json!({ +// "jsonrpc": "2.0", +// "id": 0, +// "method": "device.model" +// }) +// ) +// .await; +// } #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] From 061ffcc633c10a9b2dd871a762841328fdb54205 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Tue, 9 Sep 2025 13:49:21 +0530 Subject: [PATCH 12/13] chore: debug logs added --- device/mock_device/src/mock_device_ffi.rs | 36 +++++++++++++++++++---- device/mock_device/src/utils.rs | 17 ++++++++++- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/device/mock_device/src/mock_device_ffi.rs b/device/mock_device/src/mock_device_ffi.rs index 8c6f70ebe..1aaa9cf51 100644 --- a/device/mock_device/src/mock_device_ffi.rs +++ b/device/mock_device/src/mock_device_ffi.rs @@ -70,60 +70,84 @@ pub async fn start_service() { } async fn init(client: ServiceClient) { + info!("@@@NNA: Entered init function"); if let Some(mut extn_client) = client.get_extn_client() { + info!("@@@NNA: extn_client found, spawning websocket server"); let client_c_for_init = client.clone(); tokio::spawn(async move { match boot_ws_server(extn_client.clone()).await { Ok(server) => { + info!("@@@NNA: Websocket server started successfully"); let state = MockDeviceState::new(server); let mut methods = Methods::new(); let _ = methods.merge(MockDeviceController::new(state).into_rpc()); + info!("@@@NNA: RPC methods merged"); let processor = RPCRequestProcessor::new( extn_client.clone(), methods, ExtnId::new_channel(ExtnClassId::Device, "mock_device".into()), ); + info!("@@@NNA: RPCRequestProcessor created, adding to extn_client"); extn_client.add_request_processor(processor); } - Err(err) => panic!("websocket server failed to start. {}", err), + Err(err) => { + error!("@@@NNA: websocket server failed to start. {}", err); + panic!("websocket server failed to start. {}", err); + } }; }); + info!("@@@NNA: Initializing client_c_for_init"); client_c_for_init.initialize().await; + info!("@@@NNA: client_c_for_init initialized"); } else { - error!("Service client does not hold an extn client. Cannot start eos extension."); + error!("@@@NNA: Service client does not hold an extn client. Cannot start eos extension."); } } fn start() { + info!("@@@NNA: Entered start function"); let Ok((extn_manifest, _device_manifest)) = RippleManifestLoader::initialize() else { - error!("Error initializing manifests"); + error!("@@@NNA: Error initializing manifests"); return; }; + info!("@@@NNA: Manifests initialized successfully"); + let runtime = match Runtime::new() { - Ok(r) => r, + Ok(r) => { + info!("@@@NNA: Tokio runtime created successfully"); + r + } Err(err) => { - error!("Error creating runtime: {}", err); + error!("@@@NNA: Error creating runtime: {}", err); return; } }; let id = ExtnId::new_channel(ExtnClassId::Device, EXTN_NAME.to_string()).to_string(); + info!("@@@NNA: Generated ExtnId: {}", id); + let symbol = extn_manifest.get_extn_symbol(&id); if symbol.is_none() { - error!("Error getting symbol"); + error!("@@@NNA: Error getting symbol"); return; } + info!("@@@NNA: Extension symbol found"); + let service_client = if let Some(symbol) = symbol { + info!("@@@NNA: Building ServiceClient with extension symbol"); ServiceClient::builder().with_extension(symbol).build() } else { + info!("@@@NNA: Building ServiceClient without extension symbol"); ServiceClient::builder().build() }; + info!("@@@NNA: Starting async init in runtime"); runtime.block_on(async move { init(service_client.clone()).await; }); + info!("@@@NNA: Exiting start function"); } fn init_extn_channel() -> ExtnChannel { diff --git a/device/mock_device/src/utils.rs b/device/mock_device/src/utils.rs index 9e3aa1fac..0f8f6fd4b 100644 --- a/device/mock_device/src/utils.rs +++ b/device/mock_device/src/utils.rs @@ -37,35 +37,50 @@ use crate::{ pub async fn boot_ws_server( mut client: ExtnClient, ) -> Result, MockDeviceError> { - debug!("Booting WS Server for mock device"); + debug!("@@@NNA Booting WS Server for mock device"); let gateway = platform_gateway_url(&mut client).await?; + debug!("@@@NNA platform_gateway_url returned: {:?}", gateway); if gateway.scheme() != "ws" { + debug!("@@@NNA Bad URL scheme: {}", gateway.scheme()); return Err(BootFailedError::BadUrlScheme)?; } if !is_valid_host(gateway.host()) { + debug!("@@@NNA Bad hostname: {:?}", gateway.host()); return Err(BootFailedError::BadHostname)?; } let config = load_config(&client); + debug!("@@@NNA Loaded config: {:?}", config); let mut server_config = WsServerParameters::new(); let mock_data_v2 = load_mock_data_v2(client.clone()).await?; + debug!("@@@NNA Loaded mock data v2"); + server_config .port(gateway.port().unwrap_or(0)) .path(gateway.path()); + debug!( + "@@@NNA Server config: port={}, path={}", + gateway.port().unwrap_or(0), + gateway.path() + ); + let ws_server = MockWebSocketServer::new(mock_data_v2, server_config, config) .await .map_err(BootFailedError::ServerStartFailed)?; + debug!("@@@NNA MockWebSocketServer created"); let ws_server = Arc::new(ws_server); let server = ws_server.clone(); tokio::spawn(async move { + debug!("@@@NNA Starting WebSocket server"); server.start_server().await; }); + debug!("@@@NNA Returning ws_server Arc"); Ok(ws_server) } From 9bdc2b822e76cab6c1266a41b7058532e46d3ff9 Mon Sep 17 00:00:00 2001 From: nnaveen979 Date: Tue, 9 Sep 2025 14:43:55 +0530 Subject: [PATCH 13/13] chore: debug logs added --- device/mock_device/src/utils.rs | 15 ++- .../contracts/thunder_device_info_pacts.rs | 115 ++++++++++++++++++ 2 files changed, 128 insertions(+), 2 deletions(-) diff --git a/device/mock_device/src/utils.rs b/device/mock_device/src/utils.rs index 0f8f6fd4b..cf9e88af3 100644 --- a/device/mock_device/src/utils.rs +++ b/device/mock_device/src/utils.rs @@ -38,6 +38,10 @@ pub async fn boot_ws_server( mut client: ExtnClient, ) -> Result, MockDeviceError> { debug!("@@@NNA Booting WS Server for mock device"); + debug!( + "@@@NNA Booting WS Server for mock device client:{:?}", + client + ); let gateway = platform_gateway_url(&mut client).await?; debug!("@@@NNA platform_gateway_url returned: {:?}", gateway); @@ -85,20 +89,27 @@ pub async fn boot_ws_server( } async fn platform_gateway_url(client: &mut ExtnClient) -> Result { - debug!("sending request for config.platform_parameters"); + debug!( + "@@@NNA platform_gateway_url called with client: {:?}", + client + ); + debug!("@@@NNA sending request for config.platform_parameters"); if let Ok(response) = client.request(Config::PlatformParameters).await { + debug!("@@@NNA received response: {:?}", response); if let Some(ExtnResponse::Value(value)) = response.payload.extract() { + debug!("@@@NNA extracted value: {:?}", value); let gateway: Url = value .as_object() .and_then(|obj| obj.get("gateway")) .and_then(|val| val.as_str()) .and_then(|s| s.parse().ok()) .ok_or(BootFailedError::GetPlatformGatewayFailed)?; - debug!("{}", gateway); + debug!("@@@NNA parsed gateway URL: {}", gateway); return Ok(gateway); } } + error!("@@@NNA Failed to get platform gateway URL"); Err(BootFailedError::GetPlatformGatewayFailed)? } diff --git a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs index 3cc989017..0a15ceca2 100644 --- a/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs +++ b/device/thunder_ripple_sdk/src/tests/contracts/thunder_device_info_pacts.rs @@ -292,6 +292,121 @@ async fn test_device_get_system_verisons() { // .await; // } +#[tokio::test(flavor = "multi_thread")] +#[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] +async fn test_device_get_model() { + let mut pact_builder_async = get_pact_builder_async_obj().await; + + let mut result = HashMap::new(); + + result.insert( + "stbVersion".into(), + ContractMatcher::MatchRegex( + r"^[A-Z0-9]+_VBN_[A-Za-z0-9]+_sprint_\d{14}sdy(_[A-Z0-9_]+)*$".into(), + "AX061AEI_VBN_1911_sprint_20200109040424sdy".into(), + ), + ); + + result.insert( + "receiverVersion".into(), + ContractMatcher::MatchRegex(r"^\d+\.\d+\.\d+\.\d+$".into(), "3.14.0.0".into()), + ); + + result.insert( + "stbTimestamp".into(), + ContractMatcher::MatchRegex( + r"^\w{3} \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z ]*UTC$".into(), + "Thu 09 Jan 2020 04:04:24 AP UTC".into(), + ), + ); + result.insert("success".into(), ContractMatcher::MatchBool(true)); + + pact_builder_async + .synchronous_message_interaction("A request to get the device model", |mut i| async move { + i.contents_from(get_pact!( + "org.rdk.System.1.getSystemVersions", + ContractResult { result } + )) + .await; + i.test_name("get_device_model"); + i + }) + .await; + + let mock_server = pact_builder_async + .start_mock_server_async(Some("websockets/transport/websockets")) + .await; + + send_thunder_call_message!( + url::Url::parse(mock_server.path("/jsonrpc").as_str()) + .unwrap() + .to_string(), + json!({ + "jsonrpc": "2.0", + "id": 42, + "method": "org.rdk.System.1.getSystemVersions" + }) + ) + .await; +} + +#[tokio::test(flavor = "multi_thread")] +#[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] +async fn test_device_get_interfaces_wifi() { + let mut pact_builder_async = get_pact_builder_async_obj().await; + + pact_builder_async + .synchronous_message_interaction("A request to get the device wifi interface", |mut i| async move { + i.contents_from(json!({ + "pact:content-type": "application/json", + "request": {"jsonrpc": "matching(type, '2.0')", "id": "matching(integer, 0)", "method": "org.rdk.Network.1.getInterfaces"}, + "requestMetadata": { + "path": "/jsonrpc" + }, + "response": [{ + "jsonrpc": "matching(type, '2.0')", + "id": "matching(integer, 0)", + "result": { + "interfaces": [ + { + "interface": "matching(regex, '(WIFI|ETHERNET)', 'WIFI')", + "macAddress": "matching(regex, '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$', 'AA:AA:AA:AA:AA:AA')", + "enabled": "matching(boolean, true)", + "connected": "matching(boolean, true)" + }, + { + "interface": "matching(regex, '(WIFI|ETHERNET)', 'ETHERNET')", + "macAddress": "matching(regex, '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$', 'AA:AA:AA:AA:AA:AA')", + "enabled": "matching(boolean, true)", + "connected": "matching(boolean, false)" + } + ], + "success": true + } + }] + })).await; + i.test_name("get_device_interfaces_wifi"); + + i + }).await; + + let mock_server = pact_builder_async + .start_mock_server_async(Some("websockets/transport/websockets")) + .await; + + send_thunder_call_message!( + url::Url::parse(mock_server.path("/jsonrpc").as_str()) + .unwrap() + .to_string(), + json!({ + "jsonrpc": "2.0", + "id": 0, + "method": "org.rdk.Network.1.getInterfaces" + }) + ) + .await; +} + #[tokio::test(flavor = "multi_thread")] #[cfg_attr(not(feature = "websocket_contract_tests"), ignore)] async fn test_device_get_interfaces_ethernet() {