Skip to content

Commit

Permalink
Eth_get_filter_changes_missing (#5513)
Browse files Browse the repository at this point in the history
* Eth_get_filter_changes_missing

* Change message

* fix formating

* fix typo

* fix tests
  • Loading branch information
LukaszRozmej authored and smartprogrammer93 committed Mar 30, 2023
1 parent c4a20b6 commit 0436f7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
17 changes: 6 additions & 11 deletions src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,28 +568,23 @@ public ResultWrapper<IEnumerable<object>> eth_getFilterChanges(UInt256 filterId)
{
return _blockchainBridge.FilterExists(id)
? ResultWrapper<IEnumerable<object>>.Success(_blockchainBridge.GetBlockFilterChanges(id))
: ResultWrapper<IEnumerable<object>>.Fail($"Filter with id: '{filterId}' does not exist.");
: ResultWrapper<IEnumerable<object>>.Fail($"Filter not found", ErrorCodes.InvalidInput);
}

case FilterType.PendingTransactionFilter:
{
return _blockchainBridge.FilterExists(id)
? ResultWrapper<IEnumerable<object>>.Success(_blockchainBridge
.GetPendingTransactionFilterChanges(id))
: ResultWrapper<IEnumerable<object>>.Fail($"Filter with id: '{filterId}' does not exist.");
? ResultWrapper<IEnumerable<object>>.Success(_blockchainBridge.GetPendingTransactionFilterChanges(id))
: ResultWrapper<IEnumerable<object>>.Fail($"Filter not found", ErrorCodes.InvalidInput);
}

case FilterType.LogFilter:
{
return _blockchainBridge.FilterExists(id)
? ResultWrapper<IEnumerable<object>>.Success(
_blockchainBridge.GetLogFilterChanges(id).ToArray())
: ResultWrapper<IEnumerable<object>>.Fail($"Filter with id: '{filterId}' does not exist.");
? ResultWrapper<IEnumerable<object>>.Success(_blockchainBridge.GetLogFilterChanges(id).ToArray())
: ResultWrapper<IEnumerable<object>>.Fail($"Filter not found", ErrorCodes.InvalidInput);
}

default:
{
throw new NotSupportedException($"Filter type {filterType} is not supported");
return ResultWrapper<IEnumerable<object>>.Fail($"Filter type {filterType} is not supported.", ErrorCodes.InvalidInput);
}
}
}
Expand Down

0 comments on commit 0436f7b

Please sign in to comment.