diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index 99154f1bdb92..7ccd1df67203 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 not found\"},\"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 8df9ace79267..23163672fc07 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs @@ -568,28 +568,23 @@ public ResultWrapper> eth_getFilterChanges(UInt256 filterId) { return _blockchainBridge.FilterExists(id) ? ResultWrapper>.Success(_blockchainBridge.GetBlockFilterChanges(id)) - : ResultWrapper>.Fail($"Filter with id: '{filterId}' does not exist."); + : 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."); + ? 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."); + ? ResultWrapper>.Success(_blockchainBridge.GetLogFilterChanges(id).ToArray()) + : ResultWrapper>.Fail($"Filter not found", ErrorCodes.InvalidInput); } - default: { - throw new NotSupportedException($"Filter type {filterType} is not supported"); + return ResultWrapper>.Fail($"Filter type {filterType} is not supported.", ErrorCodes.InvalidInput); } } }