async fn client_request<'a, Out>(
        method: &str,
        params: Option<ParamsSer<'a>>,
    ) -> Result<Out, jsonrpsee::types::Error>
    where
        Out: Clone + DeserializeOwned,
    {
        let mut sleep_time_ms = 8000;
        const MAX_SLEEP_TIME_MS: u64 = 128000;

        loop {
            // Restart the server each time (and implicitly the sequencer client, which actually does the job)
            let storage = Storage::in_memory().unwrap();
            let sequencer = SeqClient::new(Chain::Goerli).unwrap();
            let api = RpcApi::new(storage, sequencer, Chain::Goerli);
            let (__handle, addr) = run_server(*LOCALHOST, api).unwrap();
            match client(addr).request::<Out>(method, params.clone()).await {
                Ok(r) => return Ok(r),
                Err(e) => match &e {
                    jsonrpsee::types::Error::Request(s)
                        if s.contains("(429 Too Many Requests)") =>
                    {
                        if sleep_time_ms > MAX_SLEEP_TIME_MS {
                            return Err(e);
                        }
                        let d = Duration::from_millis(sleep_time_ms);
                        // Give the sequencer api some slack and then retry
                        eprintln!("Got HTTP 429, retrying after {:?} ...", d);
                        tokio::time::sleep(d).await;
                        sleep_time_ms *= 2;
                    }
                    _ => return Err(e),
                },
            }
        }
    }
/// Helper wrapper to allow retrying the test if rate limiting kicks in on the sequencer API side.
///
/// Necessary until we move to mocking whatever the RPC api will call when the first release is ready.
///
/// TODO remove this wrapper when retry::Retry is used in the sequencer::Client
Helper wrapper to allow retrying the test if rate limiting kicks in on the sequencer API side.
Necessary until we move to mocking whatever the RPC api will call when the first release is ready.


Helper wrapper to allow retrying the test if rate limiting kicks in on the sequencer API side . Necessary until we move to mocking whatever the RPC api will call when the first release is ready .
async fn client_request<'a, Out>(
        method: &str,
        params: Option<ParamsSer<'a>>,
    ) -> Result<Out, jsonrpsee::types::Error>
    where
        Out: Clone + DeserializeOwned,
    {
        let mut sleep_time_ms = 8000;
        const MAX_SLEEP_TIME_MS: u64 = 128000;
        loop {
            // Restart the server each time (and implicitly the sequencer client, which actually does the job)
            let storage = Storage::in_memory().unwrap();
            let sequencer = SeqClient::new(Chain::Goerli).unwrap();
            let api = RpcApi::new(storage, sequencer, Chain::Goerli);
            let (__handle, addr) = run_server(*LOCALHOST, api).unwrap();
            match client(addr).request::<Out>(method, params.clone()).await {
                Ok(r) => return Ok(r),
                Err(e) => match &e {
                    jsonrpsee::types::Error::Request(s)
                        if s.contains("(429 Too Many Requests)") =>
                    {
                        if sleep_time_ms > MAX_SLEEP_TIME_MS {
                            return Err(e);
                        }
                        let d = Duration::from_millis(sleep_time_ms);
                        // Give the sequencer api some slack and then retry
                        eprintln!("Got HTTP 429, retrying after {:?} ...", d);
                        tokio::time::sleep(d).await;
                        sleep_time_ms *= 2;
                    }
                    _ => return Err(e),
                },
            }
        }
    }
async fn client_request < ' a , Out > ( method : & str , params : Option < ParamsSer < ' a > > , ) -> Result < Out , jsonrpsee :: types :: Error > where Out : Clone + DeserializeOwned , { let mut sleep_time_ms = 8000 ; const MAX_SLEEP_TIME_MS : u64 = 128000 ; loop { // Restart the server each time (and implicitly the sequencer client, which actually does the job) let storage = Storage :: in_memory ( ) . unwrap ( ) ; let sequencer = SeqClient :: new ( Chain :: Goerli ) . unwrap ( ) ; let api = RpcApi :: new ( storage , sequencer , Chain :: Goerli ) ; let ( __handle , addr ) = run_server ( * LOCALHOST , api ) . unwrap ( ) ; match client ( addr ) . request :: < Out > ( method , params . clone ( ) ) . await { Ok ( r ) => return Ok ( r ) , Err ( e ) => match & e { jsonrpsee :: types :: Error :: Request ( s ) if s . contains ( " " ) => { if sleep_time_ms > MAX_SLEEP_TIME_MS { return Err ( e ) ; } let d = Duration :: from_millis ( sleep_time_ms ) ; // Give the sequencer api some slack and then retry eprintln ! ( " " d ) ; tokio :: time :: sleep ( d ) . await ; sleep_time_ms *= 2 ; } _ => return Err ( e ) , } , } } }
Helper wrapper to allow retrying the test if rate limiting kicks in on the sequencer API side.
Helper wrapper to allow retrying the test if rate limiting kicks in on the sequencer API side .
method
&str
params
Option<ParamsSer<'a>>
method
&str
params
Option<ParamsSer<'a>>