From ba6d68ad31cd184d467133dc56b360d5e56d6414 Mon Sep 17 00:00:00 2001 From: dan moore Date: Wed, 5 Feb 2025 10:31:19 +0100 Subject: [PATCH 1/7] debug cast version --- .github/workflows/test-e2e.yml | 3 +++ test-runner.sh | 1 - tests/.env | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 91a0eab..623579b 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -120,6 +120,9 @@ jobs: - name: Install runner run: make install-runner + + - name: Cast Version (debug) + run: cast --version - name: Run E2E Tests run: | diff --git a/test-runner.sh b/test-runner.sh index 3d21aae..2ff1fe8 100755 --- a/test-runner.sh +++ b/test-runner.sh @@ -52,7 +52,6 @@ while [[ "$#" -gt 0 ]]; do done # 🔍 Set infra -l2_rpc_url="http://127.0.0.1:59761" if [[ "$DEPLOY_INFRA" == "true" ]]; then echo "⏳ Deploying infrastructure using Kurtosis..." diff --git a/tests/.env b/tests/.env index d7df020..dd5df8d 100644 --- a/tests/.env +++ b/tests/.env @@ -2,4 +2,5 @@ KURTOSIS_ENCLAVE=cdk TMP_CDK_FOLDER=tmp/cdk USE_L1_GAS_TOKEN_CONTRACT=true +L2_RPC_URL=http://127.0.0.1:53015 L2_SENDER_PRIVATE_KEY=0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \ No newline at end of file From b5dacdcadd0a4fe20e4fe55f3fdc40361289e2dd Mon Sep 17 00:00:00 2001 From: dan moore Date: Wed, 5 Feb 2025 12:48:33 +0100 Subject: [PATCH 2/7] local mac test hardening --- core/helpers/common-setup.bash | 2 +- core/helpers/common.bash | 69 +++++++++++++++++++++++++------- core/helpers/run-e2e.sh | 8 ++-- test-runner.sh | 5 ++- tests/.env | 2 +- tests/light/eoa-transaction.bats | 3 +- tests/light/erc20-tests.bats | 64 ++++++++++++++--------------- 7 files changed, 98 insertions(+), 55 deletions(-) diff --git a/core/helpers/common-setup.bash b/core/helpers/common-setup.bash index d619789..b1fa111 100644 --- a/core/helpers/common-setup.bash +++ b/core/helpers/common-setup.bash @@ -23,5 +23,5 @@ _common_setup() { readonly contracts_container=${KURTOSIS_CONTRACTS:-contracts-001} readonly contracts_service_wrapper=${KURTOSIS_CONTRACTS_WRAPPER:-"kurtosis service exec $enclave $contracts_container"} readonly erigon_rpc_node=${KURTOSIS_ERIGON_RPC:-cdk-erigon-rpc-001} - readonly l2_rpc_url=${L2_ETH_RPC_URL:-"$(kurtosis port print $enclave $erigon_rpc_node rpc)"} + readonly l2_rpc_url=${L2_RPC_URL:-"$(kurtosis port print $enclave $erigon_rpc_node rpc)"} } diff --git a/core/helpers/common.bash b/core/helpers/common.bash index 1978a8a..a710aac 100644 --- a/core/helpers/common.bash +++ b/core/helpers/common.bash @@ -3,7 +3,7 @@ function deploy_contract() { local rpc_url="$1" local private_key="$2" - local contract_artifact="$3" + contract_artifact="$3" # Check if rpc_url is available if [[ -z "$rpc_url" ]]; then @@ -39,6 +39,8 @@ function deploy_contract() { echo "Failed to calculate gas price" >&3 exit 1 fi + echo "Running cast send with command:" + echo "cast send --rpc-url $rpc_url --private-key $private_key --gas-price $comp_gas_price --legacy --create $bytecode" local cast_output=$(cast send --rpc-url "$rpc_url" \ --private-key "$private_key" \ --gas-price $comp_gas_price \ @@ -46,6 +48,7 @@ function deploy_contract() { --create "$bytecode" \ 2>&1) + # Check if cast send was successful if [[ $? -ne 0 ]]; then echo "Error: Failed to send transaction." @@ -56,8 +59,9 @@ function deploy_contract() { echo "Deploy contract output:" >&3 echo "$cast_output" >&3 - # Extract the contract address from the output - local deployed_contract_address=$(echo "$cast_output" | grep 'contractAddress' | sed 's/contractAddress\s\+//') + # Extract the contract address from the output using updated regex + local deployed_contract_address=$(echo "$cast_output" | grep -o 'contractAddress\s\+\(0x[a-fA-F0-9]\{40\}\)' | sed 's/contractAddress\s\+//') + local deployed_contract_address=$(echo "$deployed_contract_address" | sed -E 's/^contractAddress[[:space:]]+//') echo "Deployed contract address: $deployed_contract_address" >&3 if [[ -z "$deployed_contract_address" ]]; then @@ -259,27 +263,60 @@ function check_balances() { # Transaction hash regex: 0x followed by 64 hexadecimal characters if [[ ! "$tx_hash" =~ ^0x[a-fA-F0-9]{64}$ ]]; then - echo "Error: Invalid transaction hash: $tx_hash". + echo "Error: Invalid transaction hash: $tx_hash" return 1 fi - local sender_final_balance=$(cast balance "$sender" --ether --rpc-url "$rpc_url") || return 1 - local tx_output=$(cast tx "$tx_hash" --rpc-url "$rpc_url") - local gas_used=$(tx_output | grep '^gas ' | awk '{print $2}') - local gas_price=$(tx_output | grep '^gasPrice' | awk '{print $2}') - local gas_fee=$(echo "$gas_used * $gas_price" | bc) - local gas_fee_in_ether=$(cast to-unit "$gas_fee" ether) + local sender_final_balance=$(cast balance "$sender" --ether --rpc-url "$l2_rpc_url") || return 1 + echo "Sender final balance: '$sender_final_balance' wei" + echo "RPC url: '$l2_rpc_url'" + + # Capture transaction output + local tx_output + tx_output=$(cast tx "$tx_hash" --rpc-url "$l2_rpc_url") + if [[ $? -ne 0 ]]; then + echo "Error: Failed to fetch transaction details" + echo "$tx_output" + return 1 + fi + + # Debugging tx_output + echo "Transaction output: $tx_output" + + # Parse gas used and gas price from tx_output using updated regex + local gas_used + gas_used=$(echo "$tx_output" | grep -Eo "gas\s+[0-9]+" | awk '{print $2}') + local gas_price + gas_price=$(echo "$tx_output" | grep -Eo "gasPrice\s+[0-9]+" | awk '{print $2}') - local sender_balance_change=$(echo "$sender_initial_balance - $sender_final_balance" | bc) + # Check if gas_used and gas_price are found + if [[ -z "$gas_used" || -z "$gas_price" ]]; then + echo "Error: Gas used or gas price not found in transaction output." + return 1 + fi + + echo "Gas used: $gas_used" + echo "Gas price: $gas_price" + + local gas_fee + gas_fee=$(echo "$gas_used * $gas_price" | bc) + local gas_fee_in_ether + gas_fee_in_ether=$(cast to-unit "$gas_fee" ether) + + local sender_balance_change + sender_balance_change=$(echo "$sender_initial_balance - $sender_final_balance" | bc) echo "Sender balance changed by: '$sender_balance_change' wei" echo "Gas fee paid: '$gas_fee_in_ether' ether" - local receiver_final_balance=$(cast balance "$receiver" --ether --rpc-url "$rpc_url") || return 1 - local receiver_balance_change=$(echo "$receiver_final_balance - $receiver_initial_balance" | bc) + local receiver_final_balance + receiver_final_balance=$(cast balance "$receiver" --ether --rpc-url "$l2_rpc_url") || return 1 + local receiver_balance_change + receiver_balance_change=$(echo "$receiver_final_balance - $receiver_initial_balance" | bc) echo "Receiver balance changed by: '$receiver_balance_change' wei" # Trim 'ether' suffix from amount to get the numeric part - local value_in_ether=$(echo "$amount" | sed 's/ether$//') + local value_in_ether + value_in_ether=$(echo "$amount" | sed 's/ether$//') if ! echo "$receiver_balance_change == $value_in_ether" | bc -l; then echo "Error: receiver balance updated incorrectly. Expected: $value_in_ether, Actual: $receiver_balance_change" @@ -287,13 +324,15 @@ function check_balances() { fi # Calculate expected sender balance change - local expected_sender_change=$(echo "$value_in_ether + $gas_fee_in_ether" | bc) + local expected_sender_change + expected_sender_change=$(echo "$value_in_ether + $gas_fee_in_ether" | bc) if ! echo "$sender_balance_change == $expected_sender_change" | bc -l; then echo "Error: sender balance updated incorrectly. Expected: $expected_sender_change, Actual: $sender_balance_change" return 1 fi } + function verify_balance() { local rpc_url="$1" # RPC URL local token_addr="$2" # gas token contract address diff --git a/core/helpers/run-e2e.sh b/core/helpers/run-e2e.sh index bc640c5..cccebde 100755 --- a/core/helpers/run-e2e.sh +++ b/core/helpers/run-e2e.sh @@ -29,7 +29,6 @@ fi echo "Running tests for network: $NETWORK" echo "Using GAS_TOKEN_ADDR: $GAS_TOKEN_ADDR" -l2_rpc_url="http://127.0.0.1:59761" if [[ "$DEPLOY_INFRA" == "true" ]]; then echo "Deploying infrastructure using Kurtosis..." @@ -45,12 +44,15 @@ if [[ "$DEPLOY_INFRA" == "true" ]]; then cp "$BASE_FOLDER/config/kurtosis-cdk-node-config.toml.template" "$KURTOSIS_FOLDER/templates/trusted-node/cdk-node-config.toml" kurtosis run --enclave cdk --args-file "combinations/${NETWORK}.yml" --image-download always "$KURTOSIS_FOLDER" - l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" + kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" else echo "Skipping infrastructure deployment. Ensure the required services are already running!" fi -export L2_RPC_URL="${L2_RPC_URL:-$l2_rpc_url}" +if [[ "$L2_RPC_URL" == "" ]]; then + kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" +fi +export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" # Run selected tests with exported environment variables if [[ "$BATS_TESTS" == "all" ]]; then diff --git a/test-runner.sh b/test-runner.sh index 2ff1fe8..e0e674f 100755 --- a/test-runner.sh +++ b/test-runner.sh @@ -81,7 +81,10 @@ if [[ "$DEPLOY_INFRA" == "true" ]]; then else echo "⏩ Skipping infrastructure deployment. Ensure the required services are already running!" fi -export L2_RPC_URL="${L2_RPC_URL:-$l2_rpc_url}" +if [[ "$L2_RPC_URL" == "" ]]; then + kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" +fi +export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" # 🔍 Set BATS test files echo "🚀 Running tests with tags: $FILTER_TAGS" diff --git a/tests/.env b/tests/.env index dd5df8d..f368eaa 100644 --- a/tests/.env +++ b/tests/.env @@ -2,5 +2,5 @@ KURTOSIS_ENCLAVE=cdk TMP_CDK_FOLDER=tmp/cdk USE_L1_GAS_TOKEN_CONTRACT=true -L2_RPC_URL=http://127.0.0.1:53015 +L2_RPC_URL="" L2_SENDER_PRIVATE_KEY=0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \ No newline at end of file diff --git a/tests/light/eoa-transaction.bats b/tests/light/eoa-transaction.bats index 187c2af..9443cc6 100644 --- a/tests/light/eoa-transaction.bats +++ b/tests/light/eoa-transaction.bats @@ -6,11 +6,12 @@ setup() { _common_setup readonly sender_private_key=${SENDER_PRIVATE_KEY:-"12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"} - readonly receiver=${RECEIVER:-"0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6"} + } # bats test_tags=light,eoa @test "Send EOA transaction" { + local receiver=${RECEIVER:-"0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6"} local sender_addr=$(cast wallet address --private-key "$sender_private_key") local initial_nonce=$(cast nonce "$sender_addr" --rpc-url "$l2_rpc_url") || { echo "Failed to retrieve nonce for sender: $sender_addr using RPC URL: $l2_rpc_url" diff --git a/tests/light/erc20-tests.bats b/tests/light/erc20-tests.bats index 12665a0..6993f25 100644 --- a/tests/light/erc20-tests.bats +++ b/tests/light/erc20-tests.bats @@ -6,40 +6,38 @@ setup() { _common_setup readonly sender_private_key=${SENDER_PRIVATE_KEY:-"12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"} - readonly contract_artifact="./core/contracts/erc20mock/ERC20Mock.json" + contract_artifact="./core/contracts/erc20mock/ERC20Mock.json" } # bats test_tags=light,erc20 @test "Test ERC20Mock contract" { - # wallet_A_output=$(cast wallet new) - # address_A=$(echo "$wallet_A_output" | grep "Address" | awk '{print $2}') - # address_A_private_key=$(echo "$wallet_A_output" | grep "Private key" | awk '{print $3}') - # address_B=$(cast wallet new | grep "Address" | awk '{print $2}') - - # # Deploy ERC20Mock - # run deploy_contract "$l2_rpc_url" "$sender_private_key" "$contract_artifact" - echo $(pwd) - cat "$contract_artifact" - # assert_success - # contract_addr=$(echo "$output" | tail -n 1) - - # # Mint ERC20 tokens - # local amount="5" - # run send_tx "$l2_rpc_url" "$sender_private_key" "$contract_addr" "$mint_fn_sig" "$address_A" "$amount" - # assert_success - # assert_output --regexp "Transaction successful \(transaction hash: 0x[a-fA-F0-9]{64}\)" - - # # Insufficient gas scenario (should fail) - # local bytecode=$(jq -r .bytecode "$contract_artifact") - # [[ -z "$bytecode" || "$bytecode" == "null" ]] && { echo "Error: Failed to read bytecode"; return 1; } - - # local gas_units=$(cast estimate --rpc-url "$l2_rpc_url" --create "$bytecode") - # gas_units=$(echo "scale=0; $gas_units / 2" | bc) - # local gas_price=$(cast gas-price --rpc-url "$l2_rpc_url") - # local value=$(echo "$gas_units * $gas_price" | bc) - # local value_ether=$(cast to-unit "$value" ether)"ether" - - # cast send --rpc-url "$l2_rpc_url" --private-key "$sender_private_key" "$address_A" --value "$value_ether" --legacy - # run deploy_contract "$l2_rpc_url" "$address_A_private_key" "$contract_artifact" - # assert_failure -} + wallet_A_output=$(cast wallet new) + address_A=$(echo "$wallet_A_output" | grep "Address" | awk '{print $2}') + address_A_private_key=$(echo "$wallet_A_output" | grep "Private key" | awk '{print $3}') + address_B=$(cast wallet new | grep "Address" | awk '{print $2}') + + # Deploy ERC20Mock + run deploy_contract "$l2_rpc_url" "$sender_private_key" "$contract_artifact" + assert_success + contract_addr=$(echo "$output" | tail -n 1) + + # Mint ERC20 tokens + local amount="5" + run send_tx "$l2_rpc_url" "$sender_private_key" "$contract_addr" "$mint_fn_sig" "$address_A" "$amount" + assert_success + assert_output --regexp "Transaction successful \(transaction hash: 0x[a-fA-F0-9]{64}\)" + + # Insufficient gas scenario (should fail) + local bytecode=$(jq -r .bytecode "$contract_artifact") + [[ -z "$bytecode" || "$bytecode" == "null" ]] && { echo "Error: Failed to read bytecode"; return 1; } + + local gas_units=$(cast estimate --rpc-url "$l2_rpc_url" --create "$bytecode") + gas_units=$(echo "scale=0; $gas_units / 2" | bc) + local gas_price=$(cast gas-price --rpc-url "$l2_rpc_url") + local value=$(echo "$gas_units * $gas_price" | bc) + local value_ether=$(cast to-unit "$value" ether)"ether" + + cast send --rpc-url "$l2_rpc_url" --private-key "$sender_private_key" "$address_A" --value "$value_ether" --legacy + run deploy_contract "$l2_rpc_url" "$address_A_private_key" "$contract_artifact" + assert_failure +} \ No newline at end of file From 87eaa88be42232a2f71e853cf8fe240117b3e410 Mon Sep 17 00:00:00 2001 From: dan moore Date: Wed, 5 Feb 2025 13:05:04 +0100 Subject: [PATCH 3/7] remove kurtosis check if not needed --- test-runner.sh | 10 +++++++--- tests/.env | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test-runner.sh b/test-runner.sh index e0e674f..1a01518 100755 --- a/test-runner.sh +++ b/test-runner.sh @@ -81,10 +81,14 @@ if [[ "$DEPLOY_INFRA" == "true" ]]; then else echo "⏩ Skipping infrastructure deployment. Ensure the required services are already running!" fi -if [[ "$L2_RPC_URL" == "" ]]; then - kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" + +export L2_RPC_URL="${L2_RPC_URL:-$l2_rpc_url}" + +# Check if L2_RPC_URL is empty or not set +if [[ -z "$L2_RPC_URL" ]]; then + echo "Error: L2_RPC_URL is a required environment variable. Please update the .env file." + exit 1 # Exit the script with an error code fi -export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" # 🔍 Set BATS test files echo "🚀 Running tests with tags: $FILTER_TAGS" diff --git a/tests/.env b/tests/.env index f368eaa..beac13b 100644 --- a/tests/.env +++ b/tests/.env @@ -2,5 +2,5 @@ KURTOSIS_ENCLAVE=cdk TMP_CDK_FOLDER=tmp/cdk USE_L1_GAS_TOKEN_CONTRACT=true -L2_RPC_URL="" +L2_RPC_URL="http://127.0.0.1:53015" L2_SENDER_PRIVATE_KEY=0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \ No newline at end of file From b2889be3e802d7bfd8d9a9f31d1e0659ab6cd989 Mon Sep 17 00:00:00 2001 From: dan moore Date: Wed, 5 Feb 2025 13:09:48 +0100 Subject: [PATCH 4/7] format cleanups --- .github/workflows/test-e2e.yml | 3 --- core/helpers/common.bash | 4 ---- core/helpers/run-e2e.sh | 9 ++++++--- test-runner.sh | 1 - tests/.env | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 623579b..91a0eab 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -120,9 +120,6 @@ jobs: - name: Install runner run: make install-runner - - - name: Cast Version (debug) - run: cast --version - name: Run E2E Tests run: | diff --git a/core/helpers/common.bash b/core/helpers/common.bash index a710aac..656adb9 100644 --- a/core/helpers/common.bash +++ b/core/helpers/common.bash @@ -39,8 +39,6 @@ function deploy_contract() { echo "Failed to calculate gas price" >&3 exit 1 fi - echo "Running cast send with command:" - echo "cast send --rpc-url $rpc_url --private-key $private_key --gas-price $comp_gas_price --legacy --create $bytecode" local cast_output=$(cast send --rpc-url "$rpc_url" \ --private-key "$private_key" \ --gas-price $comp_gas_price \ @@ -48,7 +46,6 @@ function deploy_contract() { --create "$bytecode" \ 2>&1) - # Check if cast send was successful if [[ $? -ne 0 ]]; then echo "Error: Failed to send transaction." @@ -332,7 +329,6 @@ function check_balances() { fi } - function verify_balance() { local rpc_url="$1" # RPC URL local token_addr="$2" # gas token contract address diff --git a/core/helpers/run-e2e.sh b/core/helpers/run-e2e.sh index cccebde..1bbc491 100755 --- a/core/helpers/run-e2e.sh +++ b/core/helpers/run-e2e.sh @@ -49,10 +49,13 @@ else echo "Skipping infrastructure deployment. Ensure the required services are already running!" fi -if [[ "$L2_RPC_URL" == "" ]]; then - kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" +export L2_RPC_URL="${L2_RPC_URL:-$l2_rpc_url}" + +# Check if L2_RPC_URL is empty or not set +if [[ -z "$L2_RPC_URL" ]]; then + echo "Error: L2_RPC_URL is a required environment variable. Please update the .env file." + exit 1 # Exit the script with an error code fi -export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" # Run selected tests with exported environment variables if [[ "$BATS_TESTS" == "all" ]]; then diff --git a/test-runner.sh b/test-runner.sh index 1a01518..d5103b0 100755 --- a/test-runner.sh +++ b/test-runner.sh @@ -81,7 +81,6 @@ if [[ "$DEPLOY_INFRA" == "true" ]]; then else echo "⏩ Skipping infrastructure deployment. Ensure the required services are already running!" fi - export L2_RPC_URL="${L2_RPC_URL:-$l2_rpc_url}" # Check if L2_RPC_URL is empty or not set diff --git a/tests/.env b/tests/.env index beac13b..f368eaa 100644 --- a/tests/.env +++ b/tests/.env @@ -2,5 +2,5 @@ KURTOSIS_ENCLAVE=cdk TMP_CDK_FOLDER=tmp/cdk USE_L1_GAS_TOKEN_CONTRACT=true -L2_RPC_URL="http://127.0.0.1:53015" +L2_RPC_URL="" L2_SENDER_PRIVATE_KEY=0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \ No newline at end of file From 1ac5148bcdd767e02ecf115da0040459f91b6c2a Mon Sep 17 00:00:00 2001 From: dan moore Date: Wed, 5 Feb 2025 13:12:05 +0100 Subject: [PATCH 5/7] env var cleanup --- core/helpers/run-e2e.sh | 2 +- test-runner.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/helpers/run-e2e.sh b/core/helpers/run-e2e.sh index 1bbc491..37791c7 100755 --- a/core/helpers/run-e2e.sh +++ b/core/helpers/run-e2e.sh @@ -49,7 +49,7 @@ else echo "Skipping infrastructure deployment. Ensure the required services are already running!" fi -export L2_RPC_URL="${L2_RPC_URL:-$l2_rpc_url}" +export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" # Check if L2_RPC_URL is empty or not set if [[ -z "$L2_RPC_URL" ]]; then diff --git a/test-runner.sh b/test-runner.sh index d5103b0..acad481 100755 --- a/test-runner.sh +++ b/test-runner.sh @@ -77,11 +77,11 @@ if [[ "$DEPLOY_INFRA" == "true" ]]; then cp "$PROJECT_ROOT/core/helpers/config/kurtosis-cdk-node-config.toml.template" "$KURTOSIS_FOLDER/templates/trusted-node/cdk-node-config.toml" kurtosis run --enclave cdk --args-file "$PROJECT_ROOT/core/helpers/combinations/${NETWORK}.yml" --image-download always "$KURTOSIS_FOLDER" - l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" + kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" else echo "⏩ Skipping infrastructure deployment. Ensure the required services are already running!" fi -export L2_RPC_URL="${L2_RPC_URL:-$l2_rpc_url}" +export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" # Check if L2_RPC_URL is empty or not set if [[ -z "$L2_RPC_URL" ]]; then From 1303cfb4aca08cefe4f43547504eb85f7bb8eb37 Mon Sep 17 00:00:00 2001 From: dan moore Date: Wed, 5 Feb 2025 13:14:02 +0100 Subject: [PATCH 6/7] moar env var tweaks --- core/helpers/run-e2e.sh | 4 +--- test-runner.sh | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/core/helpers/run-e2e.sh b/core/helpers/run-e2e.sh index 37791c7..5b22340 100755 --- a/core/helpers/run-e2e.sh +++ b/core/helpers/run-e2e.sh @@ -44,13 +44,11 @@ if [[ "$DEPLOY_INFRA" == "true" ]]; then cp "$BASE_FOLDER/config/kurtosis-cdk-node-config.toml.template" "$KURTOSIS_FOLDER/templates/trusted-node/cdk-node-config.toml" kurtosis run --enclave cdk --args-file "combinations/${NETWORK}.yml" --image-download always "$KURTOSIS_FOLDER" - kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" + L2_RPC_URL="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" else echo "Skipping infrastructure deployment. Ensure the required services are already running!" fi -export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" - # Check if L2_RPC_URL is empty or not set if [[ -z "$L2_RPC_URL" ]]; then echo "Error: L2_RPC_URL is a required environment variable. Please update the .env file." diff --git a/test-runner.sh b/test-runner.sh index acad481..db0255d 100755 --- a/test-runner.sh +++ b/test-runner.sh @@ -77,11 +77,10 @@ if [[ "$DEPLOY_INFRA" == "true" ]]; then cp "$PROJECT_ROOT/core/helpers/config/kurtosis-cdk-node-config.toml.template" "$KURTOSIS_FOLDER/templates/trusted-node/cdk-node-config.toml" kurtosis run --enclave cdk --args-file "$PROJECT_ROOT/core/helpers/combinations/${NETWORK}.yml" --image-download always "$KURTOSIS_FOLDER" - kurtosis_l2_rpc_url="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" + L2_RPC_URL="$(kurtosis port print cdk cdk-erigon-rpc-001 rpc)" else echo "⏩ Skipping infrastructure deployment. Ensure the required services are already running!" fi -export L2_RPC_URL="${L2_RPC_URL:-$kurtosis_l2_rpc_url}" # Check if L2_RPC_URL is empty or not set if [[ -z "$L2_RPC_URL" ]]; then From 117ace758914f9506a7ea934db32eee13abfa198 Mon Sep 17 00:00:00 2001 From: dan moore Date: Wed, 5 Feb 2025 13:16:27 +0100 Subject: [PATCH 7/7] test default l2 rpc env var --- tests/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/.env b/tests/.env index f368eaa..beac13b 100644 --- a/tests/.env +++ b/tests/.env @@ -2,5 +2,5 @@ KURTOSIS_ENCLAVE=cdk TMP_CDK_FOLDER=tmp/cdk USE_L1_GAS_TOKEN_CONTRACT=true -L2_RPC_URL="" +L2_RPC_URL="http://127.0.0.1:53015" L2_SENDER_PRIVATE_KEY=0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \ No newline at end of file