Rpc: Return error if block does not exist (#11743) (#11748)

* Return error if block does not exist

* Update docs

(cherry picked from commit 747f8d5877)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
mergify[bot]
2020-08-20 22:52:18 +00:00
committed by GitHub
parent 0beb443d44
commit 7c956a87e5
3 changed files with 15 additions and 6 deletions

View File

@@ -578,7 +578,7 @@ impl JsonRpcRequestProcessor {
self.check_slot_cleaned_up(&result, slot)?;
Ok(result.ok())
} else {
Ok(None)
Err(RpcCustomError::BlockNotAvailable { slot }.into())
}
}
@@ -650,7 +650,7 @@ impl JsonRpcRequestProcessor {
self.check_slot_cleaned_up(&result, slot)?;
Ok(result.ok().unwrap_or(None))
} else {
Ok(None)
Err(RpcCustomError::BlockNotAvailable { slot }.into())
}
}
@@ -4496,7 +4496,7 @@ pub mod tests {
slot
);
let res = io.handle_request_sync(&req, meta);
let expected = r#"{"jsonrpc":"2.0","result":null,"id":1}"#;
let expected = r#"{"jsonrpc":"2.0","error":{"code":-32004,"message":"Block not available for slot 12345"},"id":1}"#;
let expected: Response =
serde_json::from_str(&expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))