From 708336cf849b255013021f481f1170f026f18306 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 30 Jul 2024 19:37:11 -0700 Subject: [PATCH] Do not error if friendbot says account already funded (#1508) --- .github/workflows/rpc-tests.yml | 2 +- .../soroban-test/tests/it/integration/fund.rs | 6 +++++- cmd/soroban-cli/src/config/network.rs | 13 +++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rpc-tests.yml b/.github/workflows/rpc-tests.yml index 72a1ec5c0..a6faba83b 100644 --- a/.github/workflows/rpc-tests.yml +++ b/.github/workflows/rpc-tests.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-22.04 services: rpc: - image: stellar/quickstart:v423-testing + image: stellar/quickstart:v438-testing ports: - 8000:8000 env: diff --git a/cmd/crates/soroban-test/tests/it/integration/fund.rs b/cmd/crates/soroban-test/tests/it/integration/fund.rs index b9a99e783..263775412 100644 --- a/cmd/crates/soroban-test/tests/it/integration/fund.rs +++ b/cmd/crates/soroban-test/tests/it/integration/fund.rs @@ -15,5 +15,9 @@ async fn fund() { .arg("fund") .arg("test") .assert() - .stderr(predicates::str::contains("funding failed")); + // Don't expect error if friendbot indicated that the account is + // already fully funded to the starting balance, because the + // user's goal is to get funded, and the account is funded + // so it is success much the same. + .success(); } diff --git a/cmd/soroban-cli/src/config/network.rs b/cmd/soroban-cli/src/config/network.rs index d332fa904..8599c0a3d 100644 --- a/cmd/soroban-cli/src/config/network.rs +++ b/cmd/soroban-cli/src/config/network.rs @@ -156,9 +156,18 @@ impl Network { tracing::debug!("{res:#?}"); if !request_successful { if let Some(detail) = res.get("detail").and_then(Value::as_str) { - return Err(Error::FundingFailed(detail.to_string())); + if detail.contains("account already funded to starting balance") { + // Don't error if friendbot indicated that the account is + // already fully funded to the starting balance, because the + // user's goal is to get funded, and the account is funded + // so it is success much the same. + tracing::debug!("already funded error ignored because account is funded"); + } else { + return Err(Error::FundingFailed(detail.to_string())); + } + } else { + return Err(Error::FundingFailed("unknown cause".to_string())); } - return Err(Error::FundingFailed("unknown cause".to_string())); } Ok(()) }