Skip to content

Commit

Permalink
Merge pull request #2238 from RolandSherwin/retry_on_register_failure
Browse files Browse the repository at this point in the history
fix(test): retry during register create to fix failures from node res…
  • Loading branch information
joshuef authored Oct 15, 2024
2 parents 23b90eb + aea6f6e commit 9279b12
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions sn_node/tests/data_with_churn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,33 @@ fn create_registers_task(

sleep(delay).await;

let register = client
.register_create(random_data, &random_name, owner, &wallet)
.await
.inspect_err(|err| {
println!("Error while creating register: {err:?}");
error!("Error while creating register: {err:?}")
})?;

let addr = register.address();
println!("Created new Register ({addr:?}) after a delay of: {delay:?}");
content
.write()
.await
.push_back(NetworkAddress::RegisterAddress(*addr));
let mut retries = 1;
loop {
match client
.register_create(random_data.clone(), &random_name, owner.clone(), &wallet)
.await
{
Ok(register) => {
let addr = register.address();
println!("Created new Register ({addr:?}) after a delay of: {delay:?}");
content
.write()
.await
.push_back(NetworkAddress::RegisterAddress(*addr));
break;
}
Err(err) => {
println!("Failed to create register: {err:?}. Retrying ...");
error!("Failed to create register: {err:?}. Retrying ...");
if retries >= 3 {
println!("Failed to create register after 3 retries: {err}");
error!("Failed to create register after 3 retries: {err}");
bail!("Failed to create register after 3 retries: {err}");
}
retries += 1;
}
}
}
}
});
handle
Expand Down

0 comments on commit 9279b12

Please sign in to comment.