From 48cffeba695f3b0676df97db4a7bd40dd3bdfb97 Mon Sep 17 00:00:00 2001 From: Gorka Date: Fri, 20 Mar 2026 15:21:41 -0300 Subject: [PATCH] Generate e2e/.env from up.sh and fix SAC deploy error up.sh now writes contract IDs, provider URL, and keys to e2e/.env so the E2E test works without knowing the provider-platform repo path. This fixes E2E on machines using non-default repo locations (BASE_DIR). Also fixed SAC deploy failing under set -e when the contract already exists on a persistent Stellar network. --- .gitignore | 1 + e2e/config.ts | 7 ++++--- up.sh | 23 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9684184..395f1d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pid *.log +e2e/.env diff --git a/e2e/config.ts b/e2e/config.ts index df496c8..bd418ad 100644 --- a/e2e/config.ts +++ b/e2e/config.ts @@ -33,15 +33,16 @@ function loadEnvFile(path: string): Record { } export function loadConfig(): Config { - // In Docker: env vars are set by docker-compose, contract IDs come from /config/contracts.env - // Locally: everything comes from the provider-platform .env file + // Priority: Docker contracts.env > local e2e/.env > provider-platform .env const contractsEnv = loadEnvFile("/config/contracts.env"); + const localEnv = loadEnvFile(new URL("./.env", import.meta.url).pathname); + const providerPlatformPath = Deno.env.get("PROVIDER_PLATFORM_PATH") ?? `${Deno.env.get("HOME")}/repos/provider-platform`; const providerEnv = loadEnvFile(`${providerPlatformPath}/.env`); - const env = { ...providerEnv, ...contractsEnv }; + const env = { ...providerEnv, ...localEnv, ...contractsEnv }; const networkPassphrase = Deno.env.get("STELLAR_NETWORK_PASSPHRASE") ?? "Standalone Network ; February 2017"; diff --git a/up.sh b/up.sh index 54d3a8d..b3297c2 100755 --- a/up.sh +++ b/up.sh @@ -160,14 +160,16 @@ WASM_DIR="target/wasm32v1-none/release" [ -f "$WASM_DIR/privacy_channel.wasm" ] || error "privacy_channel.wasm not found" info "Deploying native XLM SAC (Stellar Asset Contract)..." -TOKEN_ID=$(stellar contract asset deploy \ +if TOKEN_ID=$(stellar contract asset deploy \ --asset native \ --network local \ - --source-account "$ACCT_ADMIN") || { + --source-account "$ACCT_ADMIN" 2>/dev/null); then + info "SAC deployed" +else # SAC may already be deployed (shared network) — fetch its ID TOKEN_ID=$(stellar contract asset id --asset native --network local) warn "SAC already deployed: $TOKEN_ID" -} +fi info "XLM SAC: $TOKEN_ID" info "Deploying channel-auth contract..." @@ -408,6 +410,21 @@ for i in $(seq 1 10); do sleep 1 done +# ============================================================ +# Generate E2E config +# ============================================================ + +cat > "$SCRIPT_DIR/e2e/.env" <