message: test: Mark get_blocks_timeout retry_failed
diff: use super::utils::wait_get_blocks;
  -use crate::utils::{build_headers, sleep};
  +use crate::utils::build_headers;
  use crate::{Net, Spec, TestProtocol};
  use ckb_sync::{NetworkProtocol, BLOCK_DOWNLOAD_TIMEOUT};
  use ckb_types::core::HeaderView;
  use log::info;
  +use std::time::Instant;
  pub struct GetBlocksTimeout;
  @@ -31,24 +32,19 @@ impl Spec for GetBlocksTimeout {
  info!("Send Headers to node1");
  net.send(NetworkProtocol::SYNC.into(), pi, build_headers(&headers));
  info!("Receive GetBlocks from node1");
  - assert!(wait_get_blocks(10, &net), "timeout to wait GetBlocks");
  +
  let block_download_timeout_secs = BLOCK_DOWNLOAD_TIMEOUT / 1000;
  - let wait_get_blocks_secs = 20;
  - assert!(
  - block_download_timeout_secs > wait_get_blocks_secs,
  - "BLOCK_DOWNLOAD_TIMEOUT should greater than 20 seconds"
  - );
  - assert!(
  - !wait_get_blocks(wait_get_blocks_secs, &net),
  - "should not receive GetBlocks"
  - );
  - let sleep_secs = block_download_timeout_secs - wait_get_blocks_secs + 2;
  - sleep(sleep_secs);
  - // After about block_download_timeout_secs seconds later
  - info!(
  - "After {} seconds receive GetBlocks again from node1",
  - block_download_timeout_secs + 2
  - );
  - assert!(wait_get_blocks(10, &net), "timeout to wait GetBlocks");
  + let (first, received) = wait_get_blocks_point(block_download_timeout_secs * 2, &net);
  + assert!(received, "Should received GetBlocks");
  + let (second, received) = wait_get_blocks_point(block_download_timeout_secs * 2, &net);
  + assert!(received, "Should received GetBlocks");
  + let elapsed = second.duration_since(first).as_secs();
  + let error_margin = 2;
  + assert!(elapsed >= block_download_timeout_secs - error_margin);
  + }
  }
  +
  +fn wait_get_blocks_point(secs: u64, net: &Net) -> (Instant, bool) {
  + let flag = wait_get_blocks(secs, net);
  + (Instant::now(), flag)
  }
  