@@ -10,17 +10,17 @@ VERBOSE=false
1010
1111# Parse command line arguments
1212while [[ $# -gt 0 ]]; do
13- case $1 in
14- --verbose| -v)
15- VERBOSE=true
16- shift
17- ;;
18- * )
19- echo " Unknown option: $1 "
20- echo " Usage: $0 [--verbose]"
21- exit 1
22- ;;
23- esac
13+ case $1 in
14+ --verbose | -v)
15+ VERBOSE=true
16+ shift
17+ ;;
18+ * )
19+ echo " Unknown option: $1 "
20+ echo " Usage: $0 [--verbose]"
21+ exit 1
22+ ;;
23+ esac
2424done
2525
2626ROOT=" $( git rev-parse --show-toplevel) "
@@ -31,29 +31,29 @@ echo "Setting up foundry-uniswap-v3 tests..."
3131# Setup dependencies and submodules
3232echo " Running setup-compatibility-tests.sh..."
3333if [ " $VERBOSE " = true ]; then
34- " $ROOT /scripts/setup-compatibility-tests.sh"
34+ " $ROOT /scripts/setup-compatibility-tests.sh"
3535else
36- " $ROOT /scripts/setup-compatibility-tests.sh" > /tmp/setup-compatibility-tests.log 2>&1
36+ " $ROOT /scripts/setup-compatibility-tests.sh" > /tmp/setup-compatibility-tests.log 2>&1
3737fi
3838
3939# Launch evmd node
4040echo " Starting evmd node..."
4141pushd " $ROOT " > /dev/null
4242if [ " $VERBOSE " = true ]; then
43- ./local_node.sh -y &
43+ ./local_node.sh -y &
4444else
45- ./local_node.sh -y > /tmp/evmd.log 2>&1 &
45+ ./local_node.sh -y > /tmp/evmd.log 2>&1 &
4646fi
4747NODE_PID=$!
4848popd > /dev/null
4949
5050# Cleanup function to kill the node on exit
5151cleanup () {
52- if [ -n " $NODE_PID " ]; then
53- echo " Stopping evmd node..."
54- kill " $NODE_PID " 2> /dev/null || true
55- wait " $NODE_PID " 2> /dev/null || true
56- fi
52+ if [ -n " $NODE_PID " ]; then
53+ echo " Stopping evmd node..."
54+ kill " $NODE_PID " 2> /dev/null || true
55+ wait " $NODE_PID " 2> /dev/null || true
56+ fi
5757}
5858
5959# Set trap to cleanup on exit
@@ -70,78 +70,79 @@ TIMEOUT=60
7070ELAPSED=0
7171
7272while [ $ELAPSED -lt $TIMEOUT ]; do
73- # Get the block number from the RPC endpoint
74- RESPONSE=$( curl -s -X POST -H " Content-Type: application/json" \
75- --data ' {"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
76- " $RPC_URL " 2> /dev/null || true)
77-
78- if [ -n " $RESPONSE " ]; then
79- # Extract the hex block number from the JSON response
80- BLOCK_HEX=$( echo " $RESPONSE " | grep -o ' "result":"[^"]*"' | cut -d' "' -f4 || true)
81-
82- if [ -n " $BLOCK_HEX " ] && [ " $BLOCK_HEX " != " null" ]; then
83- # Convert hex to decimal (handle potential errors)
84- if BLOCK_NUMBER=$(( 16 #${BLOCK_HEX# 0x} 2 >/ dev / null )) ; then
85- if [ " $VERBOSE " = true ]; then
86- echo " Current block number: $BLOCK_NUMBER (waiting for >= 5)"
87- fi
88-
89- # Check if block number is >= 5
90- if [ " $BLOCK_NUMBER " -ge 5 ]; then
91- echo " Node is ready! Block number: $BLOCK_NUMBER "
92- break
93- fi
94- fi
95- fi
96- fi
97-
98- if [ " $VERBOSE " = true ]; then
99- echo " Waiting for node... ($ELAPSED /$TIMEOUT seconds)"
100- fi
101-
102- sleep 2
103- ELAPSED=$(( ELAPSED + 2 ))
73+ # Get the block number from the RPC endpoint
74+ RESPONSE=$( curl -s -X POST -H " Content-Type: application/json" \
75+ --data ' {"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
76+ " $RPC_URL " 2> /dev/null || true)
77+
78+ if [ -n " $RESPONSE " ]; then
79+ # Extract the hex block number from the JSON response
80+ BLOCK_HEX=$( echo " $RESPONSE " | grep -o ' "result":"[^"]*"' | cut -d' "' -f4 || true)
81+
82+ if [ -n " $BLOCK_HEX " ] && [ " $BLOCK_HEX " != " null" ]; then
83+ # Convert hex to decimal (handle potential errors)
84+ if BLOCK_NUMBER=$(( 16 #${BLOCK_HEX# 0x} )) ; then
85+ if [ " $VERBOSE " = true ]; then
86+ echo " Current block number: $BLOCK_NUMBER (waiting for >= 5)"
87+ fi
88+
89+ # Check if block number is >= 5
90+ if [ " $BLOCK_NUMBER " -ge 5 ]; then
91+ echo " Node is ready! Block number: $BLOCK_NUMBER "
92+ break
93+ fi
94+ fi
95+ fi
96+ fi
97+
98+ if [ " $VERBOSE " = true ]; then
99+ echo " Waiting for node... ($ELAPSED /$TIMEOUT seconds)"
100+ fi
101+
102+ sleep 2
103+ ELAPSED=$(( ELAPSED + 2 ))
104104done
105105
106106if [ $ELAPSED -ge $TIMEOUT ]; then
107- echo " Error: Node failed to reach block 5 within $TIMEOUT seconds"
108- if [ " $VERBOSE " = true ]; then
109- echo " Last response: $RESPONSE "
110- echo " Checking node logs:"
111- tail -20 /tmp/evmd.log 2> /dev/null || echo " No evmd logs found"
112- fi
113- exit 1
107+ echo " Error: Node failed to reach block 5 within $TIMEOUT seconds"
108+ if [ " $VERBOSE " = true ]; then
109+ echo " Last response: $RESPONSE "
110+ echo " Checking node logs:"
111+ tail -20 /tmp/evmd.log 2> /dev/null || echo " No evmd logs found"
112+ fi
113+ exit 1
114114fi
115115
116116# Change to the test directory
117117cd " $TEST_DIR "
118118
119119# Source the environment file
120120if [ -f " .env" ]; then
121- echo " Sourcing .env file..."
122- source .env
121+ echo " Sourcing .env file..."
122+ # shellcheck source=/dev/null
123+ source .env
123124else
124- echo " Error: .env file not found in $TEST_DIR "
125- exit 1
125+ echo " Error: .env file not found in $TEST_DIR "
126+ exit 1
126127fi
127128
128129# Verify required environment variables are set
129130if [ -z " $CUSTOM_RPC " ] || [ -z " $CHAIN_ID " ] || [ -z " $LIBRARY_CONTRACT " ]; then
130- echo " Error: Required environment variables not set"
131- echo " CUSTOM_RPC: $CUSTOM_RPC "
132- echo " CHAIN_ID: $CHAIN_ID "
133- echo " LIBRARY_CONTRACT: $LIBRARY_CONTRACT "
134- exit 1
131+ echo " Error: Required environment variables not set"
132+ echo " CUSTOM_RPC: $CUSTOM_RPC "
133+ echo " CHAIN_ID: $CHAIN_ID "
134+ echo " LIBRARY_CONTRACT: $LIBRARY_CONTRACT "
135+ exit 1
135136fi
136137
137138echo " Running foundry-uniswap-v3 deployment scripts..."
138139
139140# Deploy NFTDescriptor
140141echo " Deploying NFTDescriptor..."
141142forge script script/DeployNFTDescriptor.s.sol:DeployNFTDescriptor \
142- --rpc-url " $CUSTOM_RPC " \
143- --broadcast \
144- --chain-id " $CHAIN_ID "
143+ --rpc-url " $CUSTOM_RPC " \
144+ --broadcast \
145+ --chain-id " $CHAIN_ID "
145146
146147# Take a rest to ensure the deployment is complete
147148echo " Waiting for NFTDescriptor deployment to complete..."
@@ -150,11 +151,11 @@ sleep 5
150151# Deploy UniswapV3 with NFTDescriptor library
151152echo " Deploying UniswapV3..."
152153forge script script/DeployUniswapV3.s.sol:DeployUniswapV3 \
153- --rpc-url " $CUSTOM_RPC " \
154- --chain-id " $CHAIN_ID " \
155- --broadcast \
156- --slow \
157- --private-key " $PRIVATE_KEY " \
158- --libraries " lib/v3-periphery/contracts/libraries/NFTDescriptor.sol:NFTDescriptor:$LIBRARY_CONTRACT "
159-
160- echo " foundry-uniswap-v3 tests completed successfully!"
154+ --rpc-url " $CUSTOM_RPC " \
155+ --chain-id " $CHAIN_ID " \
156+ --broadcast \
157+ --slow \
158+ --private-key " $PRIVATE_KEY " \
159+ --libraries " lib/v3-periphery/contracts/libraries/NFTDescriptor.sol:NFTDescriptor:$LIBRARY_CONTRACT "
160+
161+ echo " foundry-uniswap-v3 tests completed successfully!"
0 commit comments