From a4ab4788d6636bc22d8e5186b3dd2639109d27e4 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Thu, 30 Mar 2023 13:21:54 +0200 Subject: [PATCH 1/5] Eth_get_filter_changes_missing --- .../Modules/Eth/EthRpcModuleTests.cs | 8 ++++ .../Modules/Eth/EthRpcModule.cs | 43 +++++++++---------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index 99154f1bdb9..08a85861134 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -245,6 +245,14 @@ public async Task Eth_get_filter_changes_empty() Assert.AreEqual("{\"jsonrpc\":\"2.0\",\"result\":[],\"id\":67}", serialized2); } + [Test] + public async Task Eth_get_filter_changes_missing() + { + using Context ctx = await Context.Create(); + string serialized2 = ctx.Test.TestEthRpc("eth_getFilterChanges", "0"); + Assert.AreEqual("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Filter with id: '0' does not exist.\"},\"id\":67}", serialized2); + } + [Test] public async Task Eth_uninstall_filter() { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index 8df9ace7926..650ea03d19f 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -565,32 +565,29 @@ public ResultWrapper> eth_getFilterChanges(UInt256 filterId) switch (filterType) { case FilterType.BlockFilter: - { - return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success(_blockchainBridge.GetBlockFilterChanges(id)) - : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist."); - } - + { + return _blockchainBridge.FilterExists(id) + ? ResultWrapper>.Success(_blockchainBridge.GetBlockFilterChanges(id)) + : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist.", ErrorCodes.InvalidInput); + } case FilterType.PendingTransactionFilter: - { - return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success(_blockchainBridge - .GetPendingTransactionFilterChanges(id)) - : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist."); - } - + { + return _blockchainBridge.FilterExists(id) + ? ResultWrapper>.Success(_blockchainBridge + .GetPendingTransactionFilterChanges(id)) + : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist.", ErrorCodes.InvalidInput); + } case FilterType.LogFilter: - { - return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success( - _blockchainBridge.GetLogFilterChanges(id).ToArray()) - : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist."); - } - + { + return _blockchainBridge.FilterExists(id) + ? ResultWrapper>.Success( + _blockchainBridge.GetLogFilterChanges(id).ToArray()) + : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist.", ErrorCodes.InvalidInput); + } default: - { - throw new NotSupportedException($"Filter type {filterType} is not supported"); - } + { + return ResultWrapper>.Fail($"$Filter type {filterType} is not supported.", ErrorCodes.InvalidInput); + } } } From 3fc349a07fa4a5fb35453bf95bf1852bcbec3b51 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Thu, 30 Mar 2023 13:24:50 +0200 Subject: [PATCH 2/5] Change message --- .../Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index 650ea03d19f..b5d2fc06033 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -568,21 +568,19 @@ public ResultWrapper> eth_getFilterChanges(UInt256 filterId) { return _blockchainBridge.FilterExists(id) ? ResultWrapper>.Success(_blockchainBridge.GetBlockFilterChanges(id)) - : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist.", ErrorCodes.InvalidInput); + : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); } case FilterType.PendingTransactionFilter: { return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success(_blockchainBridge - .GetPendingTransactionFilterChanges(id)) - : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist.", ErrorCodes.InvalidInput); + ? ResultWrapper>.Success(_blockchainBridge.GetPendingTransactionFilterChanges(id)) + : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); } case FilterType.LogFilter: { return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success( - _blockchainBridge.GetLogFilterChanges(id).ToArray()) - : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist.", ErrorCodes.InvalidInput); + ? ResultWrapper>.Success(_blockchainBridge.GetLogFilterChanges(id).ToArray()) + : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); } default: { From 3d565b3588d581b365b691b661e2c97d8701143e Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Thu, 30 Mar 2023 13:26:52 +0200 Subject: [PATCH 3/5] fix formating --- .../Modules/Eth/EthRpcModule.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index b5d2fc06033..d8295aec1d3 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -565,27 +565,27 @@ public ResultWrapper> eth_getFilterChanges(UInt256 filterId) switch (filterType) { case FilterType.BlockFilter: - { - return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success(_blockchainBridge.GetBlockFilterChanges(id)) - : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); - } + { + return _blockchainBridge.FilterExists(id) + ? ResultWrapper>.Success(_blockchainBridge.GetBlockFilterChanges(id)) + : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); + } case FilterType.PendingTransactionFilter: - { - return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success(_blockchainBridge.GetPendingTransactionFilterChanges(id)) - : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); - } + { + return _blockchainBridge.FilterExists(id) + ? ResultWrapper>.Success(_blockchainBridge.GetPendingTransactionFilterChanges(id)) + : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); + } case FilterType.LogFilter: - { - return _blockchainBridge.FilterExists(id) - ? ResultWrapper>.Success(_blockchainBridge.GetLogFilterChanges(id).ToArray()) - : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); - } + { + return _blockchainBridge.FilterExists(id) + ? ResultWrapper>.Success(_blockchainBridge.GetLogFilterChanges(id).ToArray()) + : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); + } default: - { - return ResultWrapper>.Fail($"$Filter type {filterType} is not supported.", ErrorCodes.InvalidInput); - } + { + return ResultWrapper>.Fail($"$Filter type {filterType} is not supported.", ErrorCodes.InvalidInput); + } } } From 4f36df97d8a86f61ab2e7423b66b19829cdc6b90 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Thu, 30 Mar 2023 13:27:25 +0200 Subject: [PATCH 4/5] fix typo --- src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs index d8295aec1d3..23163672fc0 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -584,7 +584,7 @@ public ResultWrapper> eth_getFilterChanges(UInt256 filterId) } default: { - return ResultWrapper>.Fail($"$Filter type {filterType} is not supported.", ErrorCodes.InvalidInput); + return ResultWrapper>.Fail($"Filter type {filterType} is not supported.", ErrorCodes.InvalidInput); } } } From 6ba954fff0c7e8fe18b3c4ce6d2875791347fd95 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Thu, 30 Mar 2023 13:47:28 +0200 Subject: [PATCH 5/5] fix tests --- .../Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index 08a85861134..7ccd1df6720 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -250,7 +250,7 @@ public async Task Eth_get_filter_changes_missing() { using Context ctx = await Context.Create(); string serialized2 = ctx.Test.TestEthRpc("eth_getFilterChanges", "0"); - Assert.AreEqual("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Filter with id: '0' does not exist.\"},\"id\":67}", serialized2); + Assert.AreEqual("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"Filter not found\"},\"id\":67}", serialized2); } [Test]