@@ -88,10 +88,11 @@ prepare_deployment() {
8888 export ARB_SEP_CHAIN_ID=421614
8989 export OP_SEP_CHAIN_ID=11155420
9090 export ETH_ADDRESS=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
91- export DEPLOY_FEES_AMOUNT=500000000000000 # 0.0005 ETH in wei
92- export FEES_AMOUNT=" 1000000000000000" # 0.001 ETH in wei
91+ export DEPLOY_FEES_AMOUNT=10000000000000000000 # 10 ETH in wei
92+ export FEES_AMOUNT=30000000000000000000 # 30 ETH in wei
93+ export TEST_USDC_AMOUNT=" 100000000" # 100 TEST USDC
9394 export GAS_BUFFER=" 100000000" # 0.1 Gwei in wei
94- export GAS_LIMIT=" 3000000 " # Gas limit estimate
95+ export GAS_LIMIT=" 50000000000 " # Gas limit estimate
9596 export EVMX_VERIFIER_URL=" https://evmx.cloud.blockscout.com/api"
9697 export EVMX_API_BASE_URL=" https://api-evmx-devnet.socket.tech"
9798}
@@ -113,11 +114,12 @@ deploy_appgateway() {
113114 --verify \
114115 --verifier-url " $EVMX_VERIFIER_URL " \
115116 --verifier blockscout \
116- --constructor-args " $ADDRESS_RESOLVER " " ( $ARB_SEP_CHAIN_ID , $ETH_ADDRESS , $ deploy_fees) " ) ; then
117+ --constructor-args " $ADDRESS_RESOLVER " " $ deploy_fees" ) ; then
117118 echo -e " ${RED} Error:${NC} Contract deployment failed."
118119 exit 1
119120 fi
120121
122+ parse_txhash " $output " " evmx.cloud"
121123 # Extract the deployed address
122124 local appgateway
123125 appgateway=$( echo " $output " | grep " Deployed to:" | awk ' {print $3}' )
@@ -137,6 +139,10 @@ function parse_txhash() {
137139 local path=$2
138140 local txhash
139141 txhash=$( echo " $output " | grep " ^transactionHash" | awk ' {print $2}' )
142+ if [ -z " $txhash " ]; then
143+ txhash=$( echo " $output " | grep -i " Transaction hash:" | awk ' {print $3}' )
144+ fi
145+
140146 # Check if txhash is empty or invalid
141147 if [ -z " $txhash " ] || ! [[ " $txhash " =~ ^0x[0-9a-fA-F]{64}$ ]]; then
142148 echo -e " ${RED} Error:${NC} Failed to extract valid transactionHash from output."
@@ -261,7 +267,7 @@ fetch_forwarder_and_onchain_address() {
261267 # Retrieve forwarder address with timeout
262268 local forwarder
263269 local attempts=0
264- local max_attempts=12 # 60 seconds / 5 second sleep = 12 attempts
270+ local max_attempts=30 # 60 seconds / 2 second sleep = 30 attempts
265271 local width=50 # Width of the progress bar
266272 local bar
267273
@@ -296,7 +302,7 @@ fetch_forwarder_and_onchain_address() {
296302 # Print progress bar on the same line
297303 printf " \r${YELLOW} Waiting for forwarder:${NC} [%-${width} s] %d%%" " $bar " " $percent "
298304
299- sleep 5
305+ sleep 2
300306 attempts=$(( attempts + 1 ))
301307 done
302308
@@ -341,75 +347,71 @@ fetch_forwarder_and_onchain_address() {
341347check_available_fees () {
342348 local max_attempts=12 # 60 seconds / 5-second interval
343349 local attempt=0
344- local available_fees=0
350+ local available_fees=" 0 "
345351 local output
346352 local width=50
347353 local bar
348-
349- while true ; do
354+ while [ $attempt -lt $max_attempts ]; do
350355 if ! output=$( cast call " $FEES_MANAGER " \
351- " getAvailableFees(uint32,address, address)(uint256)" \
352- " $ARB_SEP_CHAIN_ID " " $ APP_GATEWAY" " $ETH_ADDRESS " \
356+ " getAvailableCredits( address)(uint256)" \
357+ " $APP_GATEWAY " \
353358 --rpc-url " $EVMX_RPC " 2> /dev/null) ; then
359+ printf " \r%*s\r" $(( width + 30 )) " " # Clear the progress bar
354360 echo -e " ${RED} Error:${NC} Failed to retrieve available fees."
355361 exit 1
356362 else
357363 # Extract the fees value
358364 available_fees=$( echo " $output " | awk ' {print $1}' )
359-
360365 # Validate the fees value is a number
361366 if ! [[ " $available_fees " =~ ^[0-9]+$ ]]; then
367+ printf " \r%*s\r" $(( width + 30 )) " " # Clear the progress bar
362368 echo -e " ${RED} Error:${NC} Invalid fee value received."
363369 exit 1
364370 fi
365371 fi
366-
367372 # Check if we got non-zero fees
368- if [ " $available_fees " -ne 0 ]; then
369- if [ $attempt -ne 0 ]; then
370- printf " \n" # New line after progress bar only if not first attempt
371- fi
372- break
373- fi
374-
375- # Check if we've exceeded maximum attempts
376- if [ $attempt -ge $max_attempts ]; then
377- printf " \n" # New line before error message
378- echo -e " ${RED} Error:${NC} No funds available after 60 seconds."
379- exit 1
373+ if [ " $available_fees " != " 0" ]; then
374+ printf " \r%*s\r" $(( width + 30 )) " " # Clear the progress bar
375+ echo -e " Funds available: $available_fees wei"
376+ return 0
380377 fi
381-
382378 # Calculate progress bar
383379 local progress=$(( (attempt * width) / max_attempts ))
384380 local percent=$(( (attempt * 100 ) / max_attempts ))
385381 bar=$( printf " #%.0s" $( seq 1 $progress ) )
386-
387382 # Print progress bar on the same line
388383 printf " \r${YELLOW} Checking fees:${NC} [%-${width} s] %d%%" " $bar " " $percent "
389-
390384 sleep 5
391385 attempt=$(( attempt + 1 ))
392386 done
393-
394- echo -e " Funds available: $available_fees wei"
395- return 0
387+ # If we get here, we've exceeded maximum attempts
388+ printf " \r%*s\r" $(( width + 30 )) " " # Clear the progress bar
389+ echo -e " ${RED} Error:${NC} No funds available after 60 seconds."
390+ exit 1
396391}
397392
398393# Function to deposit funds
399394deposit_funds () {
400395 echo -e " ${CYAN} Depositing funds${NC} "
401396
397+ # Mint test USDC
398+ if ! send_transaction " $ARBITRUM_TEST_USDC " " mint(address,uint256)" " $ARBITRUM_SEPOLIA_RPC " " arbitrum-sepolia" " $WALLET_ADDRESS " " $TEST_USDC_AMOUNT " ; then
399+ echo -e " ${RED} Error:${NC} Failed to mint test USDC."
400+ return 1
401+ fi
402+
403+ # Approve USDC for FeesPlug
404+ if ! send_transaction " $ARBITRUM_TEST_USDC " " approve(address,uint256)" " $ARBITRUM_SEPOLIA_RPC " " arbitrum-sepolia" " $ARBITRUM_FEES_PLUG " " $TEST_USDC_AMOUNT " ; then
405+ echo -e " ${RED} Error:${NC} Failed to approve test USDC to FeesPlug."
406+ return 1
407+ fi
408+
402409 # Deposit funds
403- # Note: This is a special case that needs value parameter
404- if ! output=$( cast send " $ARBITRUM_FEES_PLUG " \
405- --rpc-url " $ARBITRUM_SEPOLIA_RPC " \
406- --private-key " $PRIVATE_KEY " \
407- --value " $FEES_AMOUNT " \
408- " deposit(address,address,uint256)" " $ETH_ADDRESS " " $APP_GATEWAY " " $FEES_AMOUNT " ) ; then
409- echo -e " ${RED} Error:${NC} Failed to deposit fees."
410- exit 1
410+ if ! send_transaction " $ARBITRUM_FEES_PLUG " " depositToFeeAndNative(address,address,uint256)" " $ARBITRUM_SEPOLIA_RPC " " arbitrum-sepolia" " $ARBITRUM_TEST_USDC " " $APP_GATEWAY " " $TEST_USDC_AMOUNT " ; then
411+ echo -e " ${RED} Error:${NC} Failed to deposit to fees and native."
412+ return 1
411413 fi
412- parse_txhash " $output " " arbitrum-sepolia "
414+
413415 check_available_fees
414416}
415417
@@ -420,43 +422,41 @@ withdraw_funds() {
420422 # Get available fees from EVMX chain
421423 local output
422424 if ! output=$( cast call " $FEES_MANAGER " \
423- " getAvailableFees(uint32,address, address)(uint256)" \
424- " $ARB_SEP_CHAIN_ID " " $ APP_GATEWAY" " $ETH_ADDRESS " \
425- --rpc-url " $EVMX_RPC " ) ; then
426- echo -e " ${RED} Error:${NC} Failed to get available fees."
425+ " getAvailableCredits( address)(uint256)" \
426+ " $APP_GATEWAY " \
427+ --rpc-url " $EVMX_RPC " 2> /dev/null ) ; then
428+ echo -e " ${RED} Error:${NC} Failed to retrieve available fees."
427429 exit 1
428430 fi
429431
430432 local available_fees
431433 available_fees=$( echo " $output " | awk ' {print $1}' )
432-
433- # Ensure it's a valid integer before proceeding
434+ # Validate the fees value is a number
434435 if ! [[ " $available_fees " =~ ^[0-9]+$ ]]; then
435- echo -e " ${RED} Error:${NC} Invalid available fees value: $available_fees "
436+ echo -e " ${RED} Error:${NC} Invalid fee value received. "
436437 exit 1
437438 fi
438439
439440 echo " Available Fees: $available_fees wei"
440-
441441 # Check if there are funds to withdraw
442- if [ " $available_fees " -gt 0 ]; then
442+ if [ " $available_fees " != " 0 " ]; then
443443 # Fetch gas price on Arbitrum Sepolia
444444 local arb_gas_price
445445 arb_gas_price=$( cast base-fee --rpc-url " $ARBITRUM_SEPOLIA_RPC " )
446-
447446 # Add buffer to gas price
448- local gas_price=$(( arb_gas_price + GAS_BUFFER))
449- local estimated_gas_cost=$(( GAS_LIMIT * gas_price))
450-
447+ local gas_price
448+ local estimated_gas_cost
449+ gas_price=$( echo " $arb_gas_price + $GAS_BUFFER " | bc)
450+ estimated_gas_cost=$( echo " $GAS_LIMIT * $gas_price " | bc)
451451 # Calculate withdrawal amount
452452 local amount_to_withdraw=0
453- if [ " $available_fees " -gt " $estimated_gas_cost " ] ; then
454- amount_to_withdraw=$(( available_fees - estimated_gas_cost) )
453+ if (( $(echo "$available_fees > $estimated_gas_cost " | bc - l) )) ; then
454+ amount_to_withdraw=$( echo " $ available_fees - $ estimated_gas_cost" | bc )
455455 fi
456-
457- if [ " $amount_to_withdraw " -gt 0 ] ; then
456+ echo " Withdrawing $amount_to_withdraw wei "
457+ if (( $(echo "$amount_to_withdraw > 0 " | bc - l) )) ; then
458458 # Withdraw funds using send_transaction
459- if ! send_transaction " $APP_GATEWAY " " withdrawFeeTokens(uint32,address,uint256,address)" " $EVMX_RPC " " evmx.cloud" " $ARB_SEP_CHAIN_ID " " $ETH_ADDRESS " " $amount_to_withdraw " " $SENDER_ADDRESS " ; then
459+ if ! send_transaction " $APP_GATEWAY " " withdrawFeeTokens(uint32,address,uint256,address)" " $EVMX_RPC " " evmx.cloud" " $ARB_SEP_CHAIN_ID " " $ARBITRUM_TEST_USDC " " $amount_to_withdraw " " $SENDER_ADDRESS " ; then
460460 echo -e " ${RED} Error:${NC} Failed to withdraw fees."
461461 exit 1
462462 fi
@@ -474,7 +474,7 @@ withdraw_funds() {
474474await_events () {
475475 local expected_new_events=$1 # Number of new events to expect
476476 local event=$2 # Event ABI
477- local timeout=60 # Maximum wait time in seconds
477+ local timeout=180 # Maximum wait time in seconds
478478 local interval=2 # Check every 2 seconds
479479 local elapsed=0 # Time elapsed
480480
@@ -621,7 +621,7 @@ run_read_tests() {
621621 echo -e " ${RED} Error:${NC} Failed to trigger parallel read"
622622 return 1
623623 fi
624- await_events 10
624+ await_events 10 " ValueRead(address,uint256,uint256) "
625625
626626 # 2. Trigger Alternating Read between chains
627627 if ! send_transaction " $APP_GATEWAY " " triggerAltRead(address,address)" " $EVMX_RPC " " evmx.cloud" " $OP_FORWARDER " " $ARB_FORWARDER " ; then
@@ -1099,6 +1099,7 @@ main() {
10991099 # Scheduler Tests function
11001100 run_scheduler_tests_func () {
11011101 deploy_appgateway schedule ScheduleAppGateway
1102+ deposit_funds
11021103 read_timeouts
11031104 trigger_timeouts
11041105 echo -e " ${CYAN} Waiting for the highest timeout before reading logs...${NC} "
0 commit comments