-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathintegration
executable file
·125 lines (100 loc) · 4.24 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
#!/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 ignition deployment folder exists and prompt before proceeding
if [ -d "ignition/deployments/horizon-localhost" ]; then
if [ "$NON_INTERACTIVE" = true ]; then
confirm=y
else
read -p "Ignition deployment files already exist. These must be removed for the tests to work properly. Remove them? (y/n) [y]: " confirm
confirm=${confirm:-y}
fi
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
echo "Removing existing ignition deployment files..."
rm -rf ignition/deployments/horizon-localhost
else
echo "Operation cancelled. Exiting..."
exit 1
fi
fi
if [ -f "addresses-localhost.json" ] || [ -f "../subgraph-service/addresses-localhost.json" ]; then
if [ "$NON_INTERACTIVE" = true ]; then
confirm=y
else
read -p "Address books for horizon and subgraph service will be deleted. Continue? (y/n) [y]: " confirm
confirm=${confirm:-y}
fi
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
echo "Deleting addresses-localhost.json..."
rm -f addresses-localhost.json
echo "Deleting ../subgraph-service/addresses-localhost.json..."
rm -f ../subgraph-service/addresses-localhost.json
else
echo "Operation cancelled. 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 horizon address book
jq '{"31337": ."'"$FORK_FROM_CHAIN_ID"'"}' addresses.json > addresses-localhost.json
# Setup pre horizon migration state needed for the integration tests
npx hardhat test:seed --network localhost
# Transfer ownership of protocol to hardhat signer 1
npx hardhat test:transfer-ownership --network localhost
# Step 1 - Deployer
npx hardhat deploy:migrate --network localhost --horizon-config integration --step 1
# Step 2 - Governor
npx hardhat deploy:migrate --network localhost --horizon-config integration --step 2 --patch-config --account-index 1 --hide-banner
# Step 3 - Deployer
npx hardhat deploy:migrate --network localhost --horizon-config integration --step 3 --patch-config --hide-banner
# Step 4 - Governor
npx hardhat deploy:migrate --network localhost --horizon-config integration --step 4 --patch-config --account-index 1 --hide-banner
# Unset subgraph service
npx hardhat transition:unset-subgraph-service --network localhost
# Run integration tests - During transition period
npx hardhat test:integration --phase during-transition-period --network localhost
# Clear thawing period
npx hardhat transition:clear-thawing --network localhost
# Run integration tests - After transition period
npx hardhat test:integration --phase after-transition-period --network localhost
# Enable delegation slashing
npx hardhat transition:enable-delegation-slashing --network localhost
# Run integration tests - After delegation slashing enabled
npx hardhat test:integration --phase after-delegation-slashing-enabled --network localhost
echo ""
echo "🎉 ✨ 🚀 ✅ Integration tests completed successfully! 🎉 ✨ 🚀 ✅"
echo ""