From 18d552b36c68398be63a089d8a7887a15899ce15 Mon Sep 17 00:00:00 2001 From: creeppak Date: Tue, 3 Sep 2024 15:12:37 +0100 Subject: [PATCH 1/3] Added another assert statement to throw a different message when there is connection error in UnityHttpClient.cs --- src/ChainSafe.Gaming.Unity/UnityHttpClient.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs b/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs index 0cf279fc4..5a9f63972 100644 --- a/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs +++ b/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs @@ -32,11 +32,20 @@ public UnityHttpClient(IMainThreadRunner mainThreadRunner) /// Converted Network Response. private static NetworkResponse UnityWebRequestToNetworkResponse(UnityWebRequest request) { - Assert.AreNotEqual(request.result, UnityWebRequest.Result.InProgress); - - if (request.result != UnityWebRequest.Result.Success) + // Assert response is successful { - throw new Web3Exception($"HTTP.{request.method} to {request.url} responded with error: {request.downloadHandler.text}"); + Assert.AreNotEqual(UnityWebRequest.Result.InProgress, request.result); + + if (request.result == UnityWebRequest.Result.ConnectionError) + { + throw new Web3Exception($"HTTP.{request.method} to {request.url} - connection error."); + } + + if (request.result != UnityWebRequest.Result.Success) + { + throw new Web3Exception( + $"HTTP.{request.method} to {request.url} responded with error: {request.downloadHandler.text}"); + } } return NetworkResponse.Success(request.downloadHandler.text); From 4a60d041bc515482770f6107a59f2117f1af5c9b Mon Sep 17 00:00:00 2001 From: creeppak Date: Tue, 3 Sep 2024 15:30:20 +0100 Subject: [PATCH 2/3] Slightly updated the exception message format. --- src/ChainSafe.Gaming.Unity/UnityHttpClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs b/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs index 5a9f63972..95c7b1f78 100644 --- a/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs +++ b/src/ChainSafe.Gaming.Unity/UnityHttpClient.cs @@ -38,13 +38,13 @@ private static NetworkResponse UnityWebRequestToNetworkResponse(UnityWeb if (request.result == UnityWebRequest.Result.ConnectionError) { - throw new Web3Exception($"HTTP.{request.method} to {request.url} - connection error."); + throw new Web3Exception($"HTTP.{request.method} to '{request.url}' - connection error."); } if (request.result != UnityWebRequest.Result.Success) { throw new Web3Exception( - $"HTTP.{request.method} to {request.url} responded with error: {request.downloadHandler.text}"); + $"HTTP.{request.method} to '{request.url}' responded with error: {request.downloadHandler.text}"); } } From 51d65ff39dc91dd1f37ccca207d824333feb1e19 Mon Sep 17 00:00:00 2001 From: creeppak Date: Tue, 3 Sep 2024 15:50:10 +0100 Subject: [PATCH 3/3] Made Integration tests always use hardcoded Project Config --- .../Tests/Runtime/SampleTestsBase.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Packages/io.chainsafe.web3-unity/Tests/Runtime/SampleTestsBase.cs b/Packages/io.chainsafe.web3-unity/Tests/Runtime/SampleTestsBase.cs index bd89a9d74..6765d4058 100644 --- a/Packages/io.chainsafe.web3-unity/Tests/Runtime/SampleTestsBase.cs +++ b/Packages/io.chainsafe.web3-unity/Tests/Runtime/SampleTestsBase.cs @@ -44,13 +44,10 @@ public virtual IEnumerator TearDown() internal static ValueTask BuildTestWeb3(Web3Builder.ConfigureServicesDelegate customConfiguration = null) { - // Set project config, fallback is for github as it doesn't load - var projectConfigScriptableObject = ProjectConfigUtilities.Load(); - if (projectConfigScriptableObject == null) - { - projectConfigScriptableObject = ProjectConfigUtilities.Create("3dc3e125-71c4-4511-a367-e981a6a94371", "11155111", - "Ethereum", "Sepolia", "Seth", "https://sepolia.infura.io/v3/287318045c6e455ab34b81d6bcd7a65f", "https://sepolia.etherscan.io/", false, "wss://sepolia.drpc.org"); - } + var projectConfigScriptableObject = ProjectConfigUtilities.Create("3dc3e125-71c4-4511-a367-e981a6a94371", + "11155111", + "Ethereum", "Sepolia", "Seth", "https://sepolia.infura.io/v3/287318045c6e455ab34b81d6bcd7a65f", + "https://sepolia.etherscan.io/", false, "wss://sepolia.drpc.org"); // Create web3builder & assign services var web3Builder = new Web3Builder(projectConfigScriptableObject).Configure(services =>