Skip to content

Commit

Permalink
Modify tests to serialize null on net_version
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej committed Dec 11, 2023
1 parent bab5710 commit 999ea15
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.JsonRpc.Test/JsonRpcServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Initialize()
private ILogManager _logManager = null!;
private JsonRpcContext _context = null!;

private JsonRpcResponse TestRequest<T>(T module, string method, params string[] parameters) where T : IRpcModule
private JsonRpcResponse TestRequest<T>(T module, string method, params string[]? parameters) where T : IRpcModule
{
RpcModuleProvider moduleProvider = new(new FileSystem(), _configurationProvider.GetConfig<IJsonRpcConfig>(), LimboLogs.Instance);
moduleProvider.Register(new SingletonModulePool<T>(new SingletonFactory<T>(module), true));
Expand Down Expand Up @@ -182,7 +182,7 @@ public void NetVersionTest()
{
INetRpcModule netRpcModule = Substitute.For<INetRpcModule>();
netRpcModule.net_version().ReturnsForAnyArgs(x => ResultWrapper<string>.Success("1"));
JsonRpcSuccessResponse? response = TestRequest(netRpcModule, "net_version") as JsonRpcSuccessResponse;
JsonRpcSuccessResponse? response = TestRequest(netRpcModule, "net_version", null) as JsonRpcSuccessResponse;
Assert.That(response?.Result, Is.EqualTo("1"));
Assert.IsNotInstanceOf<JsonRpcErrorResponse>(response);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.JsonRpc.Test/RpcTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public static IJsonRpcService BuildRpcService<T>(T module) where T : class, IRpc
return service;
}

public static JsonRpcRequest GetJsonRequest(string method, params string[] parameters)
public static JsonRpcRequest GetJsonRequest(string method, params string[]? parameters)
{
var doc = JsonDocument.Parse(JsonSerializer.Serialize(parameters?.ToArray() ?? Array.Empty<string>()));
var doc = JsonDocument.Parse(JsonSerializer.Serialize(parameters?.ToArray()));
var request = new JsonRpcRequest()
{
JsonRpc = "2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private void LogRequest(string methodName, JsonElement providedParameters, Param
int paramsCount = 0;
const string separator = ", ";

if (providedParameters.ValueKind != JsonValueKind.Undefined && providedParameters.ValueKind != JsonValueKind.Null)
if (providedParameters.ValueKind == JsonValueKind.Array)
{
foreach (JsonElement param in providedParameters.EnumerateArray())
{
Expand Down

0 comments on commit 999ea15

Please sign in to comment.