From 92829c7b38dee5cfef1e69b67e1629f3235fe087 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 27 Sep 2021 17:59:03 +1000 Subject: [PATCH] Add tests for block getter methods --- .../execution_layer/src/engine_api/http.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index 0445bc5c5e..c40537e3e3 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -418,6 +418,42 @@ mod test { const LOGS_BLOOM_01: &str = "0x01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"; + #[tokio::test] + async fn get_block_by_number_request() { + Tester::new() + .assert_request_equals( + |client| async move { + let _ = client + .get_block_by_number(BlockByNumberQuery::Tag(LATEST_TAG)) + .await; + }, + json!({ + "id": STATIC_ID, + "jsonrpc": JSONRPC_VERSION, + "method": ETH_GET_BLOCK_BY_NUMBER, + "params": ["latest"] + }), + ) + .await; + } + + #[tokio::test] + async fn get_block_by_hash_request() { + Tester::new() + .assert_request_equals( + |client| async move { + let _ = client.get_block_by_hash(Hash256::repeat_byte(1)).await; + }, + json!({ + "id": STATIC_ID, + "jsonrpc": JSONRPC_VERSION, + "method": ETH_GET_BLOCK_BY_HASH, + "params": [HASH_01] + }), + ) + .await; + } + #[tokio::test] async fn prepare_payload_request() { Tester::new()