Skip to content

Commit eb95ad3

Browse files
authored
fix(test): mitigate rpc snapshot test timeout by adding retry to snapshot downloading (#5960)
1 parent 9752098 commit eb95ad3

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/tool/subcommands/api_cmd/test_snapshot.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ mod tests {
187187
use anyhow::Context as _;
188188
use directories::ProjectDirs;
189189
use std::sync::LazyLock;
190-
use std::time::Instant;
190+
use std::time::{Duration, Instant};
191191
use tokio::sync::Mutex;
192192
use url::Url;
193193

@@ -216,10 +216,23 @@ mod tests {
216216
.unwrap();
217217
let project_dir = ProjectDirs::from("com", "ChainSafe", "Forest").unwrap();
218218
let cache_dir = project_dir.cache_dir().join("test").join("rpc-snapshots");
219-
let path = download_file_with_cache(&url, &cache_dir, DownloadFileOption::NonResumable)
220-
.await
221-
.unwrap()
222-
.path;
219+
let path = crate::utils::retry(
220+
crate::utils::RetryArgs {
221+
timeout: Some(Duration::from_secs(if crate::utils::is_ci() {
222+
20
223+
} else {
224+
120
225+
})),
226+
max_retries: Some(5),
227+
..Default::default()
228+
},
229+
|| async {
230+
download_file_with_cache(&url, &cache_dir, DownloadFileOption::NonResumable).await
231+
},
232+
)
233+
.await
234+
.unwrap()
235+
.path;
223236

224237
// We need to set RNG seed so that tests are run with deterministic
225238
// output. The snapshots should be generated with a node running with the same seed, if

0 commit comments

Comments
 (0)