-
Notifications
You must be signed in to change notification settings - Fork 1
268 lines (222 loc) · 10.3 KB
/
Copy pathe2e_test.yml
File metadata and controls
268 lines (222 loc) · 10.3 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
name: YieldVault Operations CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
setup-and-test:
name: YieldVault Integration Tests
runs-on: ubuntu-latest
steps:
# === COMMON SETUP ===
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
submodules: recursive
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Verify Flow CLI Installation
run: flow version
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
- name: Install Solidity dependencies
working-directory: ./solidity
run: forge install --no-git
- name: Make scripts executable
run: |
chmod +x ./local/setup_and_run_emulator.sh
chmod +x ./local/deploy_full_stack.sh
- name: Setup and Run Emulator
run: |
./local/setup_and_run_emulator.sh &
sleep 80 # Wait for the emulator to be fully up
- name: Deploy Full Stack
run: |
set -o pipefail
MAX_ATTEMPTS=2
ATTEMPT=1
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
echo "Deploy attempt $ATTEMPT/$MAX_ATTEMPTS"
if ./local/deploy_full_stack.sh 2>&1 | tee deploy_full_stack.log; then
break
fi
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo "Deploy Full Stack failed after $MAX_ATTEMPTS attempts"
exit 1
fi
echo "Deploy failed, retrying once..."
ATTEMPT=$((ATTEMPT + 1))
sleep 5
done
FLOW_VAULTS_REQUESTS_CONTRACT=$(grep "FlowYieldVaultsRequests Contract:" deploy_full_stack.log | tail -n 1 | sed 's/.*: //')
if [ -z "$FLOW_VAULTS_REQUESTS_CONTRACT" ]; then
echo "Failed to extract FlowYieldVaultsRequests contract address from deploy output"
exit 1
fi
echo "CONTRACT_ADDRESS=$FLOW_VAULTS_REQUESTS_CONTRACT" >> $GITHUB_ENV
- name: Detect Strategy Identifier
run: |
echo "Detecting supported strategy identifier..."
YIELDVAULT_CHECK=$(flow scripts execute ./cadence/scripts/check_yieldvault_details.cdc 0x045a1763c93006ca)
echo "$YIELDVAULT_CHECK"
SUPPORTED_STRATEGIES=$(echo "$YIELDVAULT_CHECK" | grep -oE '"supportedStrategies": \[[^]]*\]' || true)
if [ -z "$SUPPORTED_STRATEGIES" ]; then
echo "❌ Could not parse supported strategy list"
exit 1
fi
STRATEGY_LIST=$(echo "$SUPPORTED_STRATEGIES" | sed -E 's/^"supportedStrategies": \[(.*)\]$/\1/' | tr -d '"' | tr ',' '\n' | sed 's/^ *//;s/ *$//' | sed '/^$/d')
STRATEGY_IDENTIFIER=$(echo "$STRATEGY_LIST" | grep 'TracerStrategy' | head -n 1 || true)
if [ -z "$STRATEGY_IDENTIFIER" ]; then
STRATEGY_IDENTIFIER=$(echo "$STRATEGY_LIST" | head -n 1)
fi
if [ -z "$STRATEGY_IDENTIFIER" ]; then
echo "❌ No supported strategy identifier found"
exit 1
fi
echo "Using strategy identifier: $STRATEGY_IDENTIFIER"
echo "STRATEGY_IDENTIFIER=$STRATEGY_IDENTIFIER" >> $GITHUB_ENV
# === TEST 1: BASIC YIELDVAULT CREATION ===
- name: Test 1 - Create YieldVault (10 FLOW)
run: |
echo "========================================="
echo "TEST 1: BASIC YIELDVAULT CREATION"
echo "========================================="
forge script ./solidity/script/FlowYieldVaultsYieldVaultOperations.s.sol:FlowYieldVaultsYieldVaultOperations \
--root ./solidity \
--sig "createYieldVault(address)" ${{ env.CONTRACT_ADDRESS }} \
--rpc-url http://localhost:8545 \
--broadcast \
--legacy
env:
AMOUNT: 10000000000000000000
- name: Process Create Request
run: |
flow transactions send ./cadence/transactions/process_requests.cdc 0 10 --signer emulator-flow-yield-vaults --compute-limit 9999
- name: Verify YieldVault Creation
run: |
echo "=== Verifying YieldVault Creation ==="
# Check yieldvault details using the account-level script
YIELDVAULT_CHECK=$(flow scripts execute ./cadence/scripts/check_yieldvault_details.cdc 0x045a1763c93006ca)
echo "$YIELDVAULT_CHECK"
# Verify that we have at least one EVM address with yieldvaults
if echo "$YIELDVAULT_CHECK" | grep -q '"totalEVMAddresses": 1'; then
echo "✅ EVM address registered"
else
echo "❌ No EVM addresses found"
exit 1
fi
# Verify that we have at least one yieldvault created
if echo "$YIELDVAULT_CHECK" | grep -q '"totalMappedYieldVaults": 1'; then
echo "✅ YieldVault created successfully"
else
echo "❌ No yieldvaults found"
exit 1
fi
# Verify the specific EVM address has the yieldvault
if echo "$YIELDVAULT_CHECK" | grep -q '6813eb9362372eef6200f3b1dbc3f819671cba69'; then
echo "✅ YieldVault mapped to correct EVM address"
else
echo "❌ EVM address mapping not found"
exit 1
fi
echo "✅ Test 1 Passed: Basic yieldvault creation verified"
# === TEST 2: FULL YIELDVAULT LIFECYCLE ===
- name: Test 2 - Deposit Additional Funds (20 FLOW)
run: |
echo "========================================="
echo "TEST 2: FULL YIELDVAULT LIFECYCLE"
echo "========================================="
echo "Step 1: Depositing additional 20 FLOW..."
# Note: Using yieldvault Id 0 based on the event logs from your output
forge script ./solidity/script/FlowYieldVaultsYieldVaultOperations.s.sol:FlowYieldVaultsYieldVaultOperations \
--root ./solidity \
--sig "depositToYieldVault(address,uint64)" ${{ env.CONTRACT_ADDRESS }} 0 \
--rpc-url http://localhost:8545 \
--broadcast \
--legacy
env:
AMOUNT: 20000000000000000000
- name: Process Deposit Request
run: |
flow transactions send ./cadence/transactions/process_requests.cdc 0 10 --signer emulator-flow-yield-vaults --compute-limit 9999
- name: Verify Deposit
run: |
echo "Verifying deposit (should still have 1 yieldvault with more balance)..."
YIELDVAULT_CHECK=$(flow scripts execute ./cadence/scripts/check_yieldvault_details.cdc 0x045a1763c93006ca)
echo "$YIELDVAULT_CHECK"
# Should still have 1 yieldvault
if echo "$YIELDVAULT_CHECK" | grep -q '"totalMappedYieldVaults": 1'; then
echo "✅ Still has 1 yieldvault after deposit"
else
echo "❌ YieldVault count changed unexpectedly"
exit 1
fi
- name: Test 2 - Withdraw Half (15 FLOW)
run: |
echo "Step 2: Withdrawing 15 FLOW..."
forge script ./solidity/script/FlowYieldVaultsYieldVaultOperations.s.sol:FlowYieldVaultsYieldVaultOperations \
--root ./solidity \
--sig "withdrawFromYieldVault(address,uint64,uint256)" ${{ env.CONTRACT_ADDRESS }} 0 15000000000000000000 \
--rpc-url http://localhost:8545 \
--broadcast \
--legacy
- name: Process Withdraw Request
run: |
flow transactions send ./cadence/transactions/process_requests.cdc 0 10 --signer emulator-flow-yield-vaults --compute-limit 9999
- name: Verify Withdrawal
run: |
echo "Verifying withdrawal (should still have 1 yieldvault with less balance)..."
YIELDVAULT_CHECK=$(flow scripts execute ./cadence/scripts/check_yieldvault_details.cdc 0x045a1763c93006ca)
echo "$YIELDVAULT_CHECK"
# Should still have 1 yieldvault
if echo "$YIELDVAULT_CHECK" | grep -q '"totalMappedYieldVaults": 1'; then
echo "✅ Still has 1 yieldvault after withdrawal"
else
echo "❌ YieldVault count changed unexpectedly"
exit 1
fi
- name: Test 2 - Close YieldVault
run: |
echo "Step 3: Closing yieldvault (withdrawing remaining funds)..."
forge script ./solidity/script/FlowYieldVaultsYieldVaultOperations.s.sol:FlowYieldVaultsYieldVaultOperations \
--root ./solidity \
--sig "closeYieldVault(address,uint64)" ${{ env.CONTRACT_ADDRESS }} 0 \
--rpc-url http://localhost:8545 \
--broadcast \
--legacy
- name: Process Close Request
run: |
flow transactions send ./cadence/transactions/process_requests.cdc 0 10 --signer emulator-flow-yield-vaults --compute-limit 9999
- name: Verify YieldVault Closed
run: |
echo "Verifying yieldvault was closed..."
YIELDVAULT_CHECK=$(flow scripts execute ./cadence/scripts/check_yieldvault_details.cdc 0x045a1763c93006ca)
echo "$YIELDVAULT_CHECK"
# After closing, should have 0 yieldvaults or the yieldvault should be marked as closed
if echo "$YIELDVAULT_CHECK" | grep -q '"totalMappedYieldVaults": 0'; then
echo "✅ YieldVault successfully closed and removed"
elif echo "$YIELDVAULT_CHECK" | grep -q '"totalEVMAddresses": 0'; then
echo "✅ No more active yieldvaults for EVM addresses"
else
echo "⚠️ YieldVault may still exist but should be in closed state"
# Don't fail here as the close transaction succeeded
fi
echo "✅ Test 2 Passed: Full yieldvault lifecycle completed"
# === FINAL SUMMARY ===
- name: Test Summary
run: |
echo "========================================="
echo "ALL INTEGRATION TESTS PASSED"
echo "========================================="
echo "✅ Test 1: Basic YieldVault Creation - PASSED"
echo "✅ Test 2: Full YieldVault Lifecycle - PASSED"
echo "========================================="