Skip to content

Commit efc6162

Browse files
committed
Updated with tests
1 parent 6a25ece commit efc6162

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

bin/reth/tests/commands/bitfinity_node_it.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,57 @@ async fn bitfinity_test_should_start_local_reth_node() {
4949
assert!(reth_client.get_chain_id().await.is_ok());
5050
}
5151

52+
#[tokio::test]
53+
async fn bitfinity_test_lb_lag_check() {
54+
// Arrange
55+
let _log = init_logs();
56+
57+
let eth_server = EthImpl::new();
58+
let (_server, eth_server_address) =
59+
mock_eth_server_start(EthServer::into_rpc(eth_server)).await;
60+
let (reth_client, _reth_node) =
61+
start_reth_node(Some(format!("http://{}", eth_server_address)), None).await;
62+
63+
// Try `eth_lbLagCheck`
64+
let result: String = reth_client
65+
.single_request(
66+
"eth_lbLagCheck".to_owned(),
67+
ethereum_json_rpc_client::Params::Array(vec![10.into()]),
68+
ethereum_json_rpc_client::Id::Num(1),
69+
)
70+
.await
71+
.unwrap();
72+
73+
assert!(result.contains("ACCEPTED_LAG"), "{result:?}");
74+
75+
// Need time to generate extra blocks at `eth_server`
76+
// Assuming it ticks 100ms for the next block
77+
tokio::time::sleep(std::time::Duration::from_millis(1500)).await;
78+
79+
let result: String = reth_client
80+
.single_request(
81+
"eth_lbLagCheck".to_owned(),
82+
ethereum_json_rpc_client::Params::Array(vec![5.into()]),
83+
ethereum_json_rpc_client::Id::Num(1),
84+
)
85+
.await
86+
.unwrap();
87+
88+
assert!(result.contains("LAGGING"), "{result:?}");
89+
90+
// Default accepted lag is 3 so it should be lagging too
91+
let result: String = reth_client
92+
.single_request(
93+
"eth_lbLagCheck".to_owned(),
94+
ethereum_json_rpc_client::Params::None,
95+
ethereum_json_rpc_client::Id::Num(1),
96+
)
97+
.await
98+
.unwrap();
99+
100+
assert!(result.contains("LAGGING"), "{result:?}");
101+
}
102+
52103
#[tokio::test]
53104
async fn bitfinity_test_node_forward_ic_or_eth_get_last_certified_block() {
54105
// Arrange

crates/rpc/rpc-eth-api/src/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ where
399399
Ok(block) => block,
400400
Err(e) => {
401401
// Must not fail if rpc-url/evmc is not responding
402-
// or it would to break nodes cluster -> LB will stop traffic
402+
// or it could've disable all nodes under LB
403403
tracing::error!(target: "rpc::eth", "Failed to get block number from the network. {}", e);
404404
return Ok(format!("{}: NO_SOURCE", LAG_STATUS_OK));
405405
}

0 commit comments

Comments
 (0)