@@ -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]
53104async fn bitfinity_test_node_forward_ic_or_eth_get_last_certified_block ( ) {
54105 // Arrange
0 commit comments