Skip to content

Commit

Permalink
Better wallet error message (ordinals#3272)
Browse files Browse the repository at this point in the history
  • Loading branch information
bingryan committed Mar 13, 2024
1 parent fd15242 commit 9dc453f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ impl Wallet {
if !no_sync {
for i in 0.. {
let response = async_ord_client.get("/blockcount").await?;
if response.text().await?.parse::<u64>().unwrap() >= chain_block_count {
if response
.text()
.await?
.parse::<u64>()
.expect("wallet failed to talk to server. Make sure `ord server` is running.")
>= chain_block_count
{
break;
} else if i == 20 {
bail!("wallet failed to synchronize with ord server");
bail!("wallet failed to synchronize with `ord server` after {i} attempts");
}
tokio::time::sleep(Duration::from_millis(50)).await;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/wallet/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn unsynced_wallet_fails_with_unindexed_output() {
.ord_rpc_server(&no_sync_ord_rpc_server)
.bitcoin_rpc_server(&bitcoin_rpc_server)
.expected_exit_code(1)
.expected_stderr("error: wallet failed to synchronize with ord server\n")
.expected_stderr("error: wallet failed to synchronize with `ord server` after 20 attempts\n")
.run_and_extract_stdout();

CommandBuilder::new("wallet --no-sync balance")
Expand Down

0 comments on commit 9dc453f

Please sign in to comment.