From 301da2a8a19958b722532836b4b5d9b4f254d7dc Mon Sep 17 00:00:00 2001 From: tgmichel Date: Thu, 22 Jun 2023 02:21:42 +0200 Subject: [PATCH] `eth_getLogs` return expected error/message for unknown hash (#1079) * `eth_getLogs` return expected error/message for unknown hash * prettier --- client/rpc/src/eth/filter.rs | 2 +- ts-tests/tests/test-log-filtering.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/rpc/src/eth/filter.rs b/client/rpc/src/eth/filter.rs index 458b917fa8..00543aa4d3 100644 --- a/client/rpc/src/eth/filter.rs +++ b/client/rpc/src/eth/filter.rs @@ -371,7 +371,7 @@ where .map_err(|err| internal_err(format!("{:?}", err)))? { Some(hash) => hash, - _ => return Ok(Vec::new()), + _ => return Err(crate::err(-32000, "unknown block", None)), }; let schema = fc_storage::onchain_storage_schema(client.as_ref(), substrate_hash); diff --git a/ts-tests/tests/test-log-filtering.ts b/ts-tests/tests/test-log-filtering.ts index d44c2beab4..b1bf7d95e9 100644 --- a/ts-tests/tests/test-log-filtering.ts +++ b/ts-tests/tests/test-log-filtering.ts @@ -83,4 +83,14 @@ describeWithFrontier("Frontier RPC (Log filtering)", (context) => { expect(request.result.length).to.be.eq(0); } }); + + step("EthApi::getLogs - should return `unknown block`.", async function () { + let request = await customRequest(context.web3, "eth_getLogs", [ + { + blockHash: "0x1234000000000000000000000000000000000000000000000000000000000000", + }, + ]); + expect(request.error.message).to.be.equal("unknown block"); + expect(request.error.code).to.be.equal(-32000); + }); });