-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathintegration
executable file
Β·137 lines (109 loc) Β· 4.78 KB
/
integration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
set -eo pipefail
NON_INTERACTIVE=${NON_INTERACTIVE:-false}
# Set environment variables for this script
export SECURE_ACCOUNTS_DISABLE_PROVIDER=true
export FORK_FROM_CHAIN_ID=${FORK_FROM_CHAIN_ID:-421614}
# Function to cleanup resources
cleanup() {
# Kill hardhat node only if we started it
if [ ! -z "$NODE_PID" ] && [ "$STARTED_NODE" = true ]; then
echo "Cleaning up node process..."
kill $NODE_PID 2>/dev/null || true
fi
}
# Set trap to call cleanup function on script exit (normal or error)
trap cleanup EXIT
# Check if any deployment folders exist
SUBGRAPH_DEPLOYMENT_EXISTS=false
HORIZON_DEPLOYMENT_EXISTS=false
if [ -d "ignition/deployments/subgraph-service-localhost" ]; then
SUBGRAPH_DEPLOYMENT_EXISTS=true
fi
if [ -d "../horizon/ignition/deployments/horizon-localhost" ]; then
HORIZON_DEPLOYMENT_EXISTS=true
fi
# If any deployment exists, ask once for confirmation
if [ "$SUBGRAPH_DEPLOYMENT_EXISTS" = true ] || [ "$HORIZON_DEPLOYMENT_EXISTS" = true ]; then
echo "The following deployment files already exist and must be removed for the tests to work properly:"
if [ "$SUBGRAPH_DEPLOYMENT_EXISTS" = true ]; then
echo "- Subgraph Service: ignition/deployments/subgraph-service-localhost"
fi
if [ "$HORIZON_DEPLOYMENT_EXISTS" = true ]; then
echo "- Horizon: ../horizon/ignition/deployments/horizon-localhost"
fi
read -p "Remove these deployment files? (y/n) [y]: " confirm
confirm=${confirm:-y}
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
if [ "$SUBGRAPH_DEPLOYMENT_EXISTS" = true ]; then
echo "Removing Subgraph Service deployment files..."
rm -rf ignition/deployments/subgraph-service-localhost
fi
if [ "$HORIZON_DEPLOYMENT_EXISTS" = true ]; then
echo "Removing Horizon deployment files..."
rm -rf ../horizon/ignition/deployments/horizon-localhost
fi
else
echo "Cannot continue with existing deployment files. Exiting."
exit 1
fi
fi
# Check required env variables
BLOCKCHAIN_RPC=${BLOCKCHAIN_RPC:-$(npx hardhat vars get ARBITRUM_SEPOLIA_RPC)}
if [ -z "$BLOCKCHAIN_RPC" ]; then
echo "BLOCKCHAIN_RPC environment variable is required"
exit 1
fi
echo "Starting integration tests..."
# Check if hardhat node is already running on port 8545
STARTED_NODE=false
if lsof -i:8545 > /dev/null 2>&1; then
echo "Hardhat node already running on port 8545, using existing node"
# Get the PID of the process using port 8545
NODE_PID=$(lsof -t -i:8545)
else
# Start local hardhat node forked from Arbitrum Sepolia
echo "Starting local hardhat node..."
npx hardhat node --fork $BLOCKCHAIN_RPC > node.log 2>&1 &
NODE_PID=$!
STARTED_NODE=true
# Wait for node to start
sleep 10
fi
# Setup subgraph service address book
jq '{"31337": ."'"$FORK_FROM_CHAIN_ID"'"}' addresses.json > addresses-localhost.json
# Run Horizon pre-upgrade steps
cd ../horizon
# Setup pre horizon migration state needed for the e2e tests
npx hardhat test:seed --network localhost
# Transfer ownership of protocol to hardhat signer 1
npx hardhat test:transfer-ownership --network localhost
# Run Horizon steps 1 deployment
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 1 --account-index 0 --patch-config
# Run Subgraph Service steps 1 deployment
cd ../subgraph-service
npx hardhat deploy:migrate --network localhost --step 1 --subgraph-service-config integration-test --patch-config --account-index 0 --hide-banner
# Run Horizon deployment steps 2 and 3
cd ../horizon
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 2 --patch-config --account-index 1 --hide-banner
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 3 --patch-config --account-index 0 --hide-banner
# Run Subgraph Service deployment step 2
cd ../subgraph-service
npx hardhat deploy:migrate --network localhost --step 2 --subgraph-service-config integration-test --patch-config --account-index 0 --hide-banner
# Run Horizon deployment steps 4
cd ../horizon
npx hardhat deploy:migrate --network localhost --horizon-config e2e-test --step 4 --patch-config --account-index 1 --hide-banner
# Run Subgraph Service seed steps
cd ../subgraph-service
npx hardhat test:seed --network localhost
# Run integration tests - During transition period
npx hardhat test:integration --phase during-transition-period --network localhost
# Clear thawing period
cd ../horizon
npx hardhat transition:clear-thawing --network localhost --governor-index 1
# Run integration tests - After transition period
cd ../subgraph-service
npx hardhat test:integration --phase after-transition-period --network localhost
echo ""
echo "π β¨ π β
E2E tests completed successfully! π β¨ π β
"
echo ""