Skip to content

Commit

Permalink
eth_getLogs return expected error/message for unknown hash (#1079)
Browse files Browse the repository at this point in the history
* `eth_getLogs` return expected error/message for unknown hash

* prettier
  • Loading branch information
tgmichel authored Jun 22, 2023
1 parent 0c1680b commit ab3d355
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/rpc/src/eth/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,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);

Expand Down
10 changes: 10 additions & 0 deletions ts-tests/tests/test-log-filtering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit ab3d355

Please sign in to comment.