1
+ #! /bin/bash
2
+
3
+ set -eo pipefail
4
+
5
+ # Save original environment variable values
6
+ ORIGINAL_HARDHAT_FORK=${HARDHAT_FORK:- " " }
7
+ ORIGINAL_SECURE_ACCOUNTS_DISABLE_PROVIDER=${SECURE_ACCOUNTS_DISABLE_PROVIDER:- " " }
8
+
9
+ # Set environment variables for this script
10
+ export HARDHAT_FORK=true
11
+ export SECURE_ACCOUNTS_DISABLE_PROVIDER=true
12
+
13
+ # Function to cleanup resources
14
+ cleanup () {
15
+ # Remove ignition deployment files
16
+ echo " Removing ignition deployment files..."
17
+ rm -rf ignition/deployments/horizon-localhost
18
+
19
+ # Kill hardhat node only if we started it
20
+ if [ ! -z " $NODE_PID " ] && [ " $STARTED_NODE " = true ]; then
21
+ echo " Cleaning up node process..."
22
+ kill $NODE_PID 2> /dev/null || true
23
+ fi
24
+
25
+ # Restore original environment variables
26
+ echo " Restoring original environment variables..."
27
+ if [ -z " $ORIGINAL_HARDHAT_FORK " ]; then
28
+ unset HARDHAT_FORK
29
+ else
30
+ export HARDHAT_FORK=" $ORIGINAL_HARDHAT_FORK "
31
+ fi
32
+
33
+ if [ -z " $ORIGINAL_SECURE_ACCOUNTS_DISABLE_PROVIDER " ]; then
34
+ unset SECURE_ACCOUNTS_DISABLE_PROVIDER
35
+ else
36
+ export SECURE_ACCOUNTS_DISABLE_PROVIDER=" $ORIGINAL_SECURE_ACCOUNTS_DISABLE_PROVIDER "
37
+ fi
38
+ }
39
+
40
+ # Set trap to call cleanup function on script exit (normal or error)
41
+ trap cleanup EXIT
42
+
43
+ # Check required env variables
44
+ if [ -z " $ARBITRUM_SEPOLIA_RPC " ]; then
45
+ echo " ARBITRUM_SEPOLIA_RPC environment variable is required"
46
+ exit 1
47
+ fi
48
+
49
+ echo " Starting e2e tests..."
50
+
51
+ # Check if hardhat node is already running on port 8545
52
+ STARTED_NODE=false
53
+ if lsof -i:8545 > /dev/null 2>&1 ; then
54
+ echo " Hardhat node already running on port 8545, using existing node"
55
+ # Get the PID of the process using port 8545
56
+ NODE_PID=$( lsof -t -i:8545)
57
+ else
58
+ # Start local hardhat node forked from Arbitrum Sepolia
59
+ echo " Starting local hardhat node..."
60
+ npx hardhat node --fork $ARBITRUM_SEPOLIA_RPC > node.log 2>&1 &
61
+ NODE_PID=$!
62
+ STARTED_NODE=true
63
+
64
+ # Wait for node to start
65
+ sleep 10
66
+ fi
67
+
68
+ # Setup pre horizon migration state needed for the e2e tests
69
+ npx hardhat run ./scripts/e2e/pre-upgrade.ts --network localhost
70
+
71
+ # Transfer ownership of protocol to hardhat signer 1
72
+ npx hardhat run ./scripts/e2e/transfer-ownership.ts --network localhost
73
+
74
+ # Step 1 - Deployer
75
+ npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 1 --signer-index 0
76
+
77
+ # Step 2 - Governor
78
+ npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 2 --patch-config --signer-index 1 --hide-banner
79
+
80
+ # Step 3 - Deployer
81
+ npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 3 --patch-config --signer-index 0 --hide-banner
82
+
83
+ # Step 4 - Governor
84
+ npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 4 --patch-config --signer-index 1 --hide-banner
85
+
86
+ # Unset subgraph service
87
+ npx hardhat transition:unset-subgraph-service --network localhost --governor-index 1
88
+
89
+ # Run integration tests - During transition period
90
+ npx hardhat test:integration --phase during-transition-period --network localhost
91
+
92
+ # Clear thawing period
93
+ npx hardhat transition:clear-thawing --network localhost --governor-index 1
94
+
95
+ # Run integration tests - After transition period
96
+ npx hardhat test:integration --phase after-transition-period --network localhost
97
+
98
+ # Enable delegation slashing
99
+ npx hardhat transition:enable-delegation-slashing --network localhost --governor-index 1
100
+
101
+ # Run integration tests - After delegation slashing enabled
102
+ npx hardhat test:integration --phase after-delegation-slashing-enabled --network localhost
103
+
104
+ echo " "
105
+ echo " 🎉 ✨ 🚀 ✅ E2E tests completed successfully! 🎉 ✨ 🚀 ✅"
106
+ echo " "
0 commit comments