-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_conversion.sh
More file actions
executable file
·237 lines (197 loc) · 7.69 KB
/
validate_conversion.sh
File metadata and controls
executable file
·237 lines (197 loc) · 7.69 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
#!/bin/bash
# EpicChain C++ SDK Conversion Validation Script
# This script validates the completeness and correctness of the Swift to C++ conversion
set -e
echo "================================================"
echo "EpicChain C++ SDK Conversion Validation"
echo "================================================"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Counters
TOTAL_CHECKS=0
PASSED_CHECKS=0
FAILED_CHECKS=0
WARNINGS=0
# Function to run a check
run_check() {
local description="$1"
local command="$2"
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
echo -n "Checking: $description... "
if eval "$command" > /dev/null 2>&1; then
echo -e "${GREEN}✓ PASS${NC}"
PASSED_CHECKS=$((PASSED_CHECKS + 1))
return 0
else
echo -e "${RED}✗ FAIL${NC}"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
return 1
fi
}
# Function to run a warning check
warning_check() {
local description="$1"
local command="$2"
echo -n "Checking: $description... "
if eval "$command" > /dev/null 2>&1; then
echo -e "${GREEN}✓ OK${NC}"
else
echo -e "${YELLOW}⚠ WARNING${NC}"
WARNINGS=$((WARNINGS + 1))
fi
}
echo ""
echo "1. Directory Structure Validation"
echo "---------------------------------"
run_check "Include directory exists" "[ -d include/epicchaincpp ]"
run_check "Source directory exists" "[ -d src ]"
run_check "Tests directory exists" "[ -d tests ]"
run_check "Examples directory exists" "[ -d examples ]"
run_check "CMakeLists.txt exists" "[ -f CMakeLists.txt ]"
echo ""
echo "2. Core Headers Validation"
echo "--------------------------"
# Crypto headers
run_check "BIP39 header exists" "[ -f include/epicchaincpp/crypto/bip39.hpp ]"
run_check "EC key pair header exists" "[ -f include/epicchaincpp/crypto/ec_key_pair.hpp ]"
run_check "Hash header exists" "[ -f include/epicchaincpp/crypto/hash.hpp ]"
run_check "XEP2 header exists" "[ -f include/epicchaincpp/crypto/xep2.hpp ]"
run_check "WIF header exists" "[ -f include/epicchaincpp/crypto/wif.hpp ]"
# Wallet headers
run_check "Account header exists" "[ -f include/epicchaincpp/wallet/account.hpp ]"
run_check "BIP39 account header exists" "[ -f include/epicchaincpp/wallet/bip39_account.hpp ]"
run_check "Wallet header exists" "[ -f include/epicchaincpp/wallet/wallet.hpp ]"
# Protocol headers
run_check "Neo protocol header exists" "[ -f include/epicchaincpp/protocol/core/neo.hpp ]"
# Response type headers
run_check "NeoGetClaimable header exists" "[ -f include/epicchaincpp/protocol/core/response/epicchain_get_claimable.hpp ]"
run_check "NeoGetTokenBalances header exists" "[ -f include/epicchaincpp/protocol/core/response/epicchain_get_token_balances.hpp ]"
run_check "NeoGetTokenTransfers header exists" "[ -f include/epicchaincpp/protocol/core/response/epicchain_get_token_transfers.hpp ]"
run_check "NeoGetWalletBalance header exists" "[ -f include/epicchaincpp/protocol/core/response/epicchain_get_wallet_balance.hpp ]"
run_check "ExpressContractState header exists" "[ -f include/epicchaincpp/protocol/core/response/express_contract_state.hpp ]"
run_check "ExpressShutdown header exists" "[ -f include/epicchaincpp/protocol/core/response/express_shutdown.hpp ]"
run_check "Transaction response header exists" "[ -f include/epicchaincpp/protocol/core/response/transaction.hpp ]"
echo ""
echo "3. Source Files Validation"
echo "--------------------------"
run_check "BIP39 account source exists" "[ -f src/wallet/bip39_account.cpp ]"
warning_check "BIP39 source exists" "[ -f src/crypto/bip39.cpp ]"
echo ""
echo "4. Swift Parity Check"
echo "---------------------"
# Count Swift files
SWIFT_COUNT=$(find ../Sources/EpicChainSwift -name "*.swift" 2>/dev/null | wc -l | tr -d ' ')
echo "Swift source files: $SWIFT_COUNT"
# Count C++ files
CPP_HEADERS=$(find include -name "*.hpp" -o -name "*.h" 2>/dev/null | wc -l | tr -d ' ')
CPP_SOURCES=$(find src -name "*.cpp" -o -name "*.cc" 2>/dev/null | wc -l | tr -d ' ')
CPP_TOTAL=$((CPP_HEADERS + CPP_SOURCES))
echo "C++ files (headers + sources): $CPP_TOTAL"
# Calculate parity percentage
if [ "$SWIFT_COUNT" -gt 0 ]; then
PARITY=$(( (CPP_TOTAL * 100) / SWIFT_COUNT ))
echo "Conversion parity: ${PARITY}%"
if [ "$PARITY" -ge 80 ]; then
echo -e "${GREEN}✓ Good parity (≥80%)${NC}"
elif [ "$PARITY" -ge 60 ]; then
echo -e "${YELLOW}⚠ Acceptable parity (60-80%)${NC}"
else
echo -e "${RED}✗ Low parity (<60%)${NC}"
fi
fi
echo ""
echo "5. Compilation Test"
echo "-------------------"
# Check if build directory exists, create if not
if [ ! -d "build" ]; then
echo "Creating build directory..."
mkdir -p build
fi
# Try to configure with CMake
echo -n "CMake configuration... "
if cd build && cmake .. > /dev/null 2>&1; then
echo -e "${GREEN}✓ SUCCESS${NC}"
# Try to build
echo -n "Building project... "
if make -j4 > /dev/null 2>&1; then
echo -e "${GREEN}✓ SUCCESS${NC}"
PASSED_CHECKS=$((PASSED_CHECKS + 2))
else
echo -e "${YELLOW}⚠ Build failed (may need dependencies)${NC}"
WARNINGS=$((WARNINGS + 1))
fi
cd ..
else
echo -e "${YELLOW}⚠ CMake configuration failed${NC}"
WARNINGS=$((WARNINGS + 1))
cd ..
fi
echo ""
echo "6. Documentation Check"
echo "----------------------"
run_check "README.md exists" "[ -f README.md ]"
run_check "Conversion report exists" "[ -f SWIFT_TO_CPP_CONVERSION_FINAL_REPORT.md ]"
warning_check "API documentation exists" "[ -d docs ]"
echo ""
echo "7. Test Coverage Check"
echo "----------------------"
TEST_COUNT=$(find tests -name "*.cpp" 2>/dev/null | wc -l | tr -d ' ')
echo "Test files found: $TEST_COUNT"
if [ "$TEST_COUNT" -ge 20 ]; then
echo -e "${GREEN}✓ Good test coverage${NC}"
elif [ "$TEST_COUNT" -ge 10 ]; then
echo -e "${YELLOW}⚠ Moderate test coverage${NC}"
WARNINGS=$((WARNINGS + 1))
else
echo -e "${RED}✗ Low test coverage${NC}"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
fi
echo ""
echo "8. Critical Components Check"
echo "-----------------------------"
# Check for TODOs and placeholders
echo -n "Checking for TODO comments... "
TODO_COUNT=$(grep -r "TODO" include src 2>/dev/null | grep -v "Binary file" | wc -l | tr -d ' ')
if [ "$TODO_COUNT" -eq 0 ]; then
echo -e "${GREEN}✓ No TODOs found${NC}"
else
echo -e "${YELLOW}⚠ Found $TODO_COUNT TODO comments${NC}"
WARNINGS=$((WARNINGS + 1))
fi
echo -n "Checking for placeholder implementations... "
PLACEHOLDER_COUNT=$(grep -r "throw.*not.*implemented\|placeholder\|stub" include src 2>/dev/null | grep -v "Binary file" | wc -l | tr -d ' ')
if [ "$PLACEHOLDER_COUNT" -eq 0 ]; then
echo -e "${GREEN}✓ No placeholders found${NC}"
else
echo -e "${YELLOW}⚠ Found $PLACEHOLDER_COUNT potential placeholders${NC}"
WARNINGS=$((WARNINGS + 1))
fi
echo ""
echo "================================================"
echo "Validation Summary"
echo "================================================"
echo "Total checks performed: $TOTAL_CHECKS"
echo -e "Passed: ${GREEN}$PASSED_CHECKS${NC}"
echo -e "Failed: ${RED}$FAILED_CHECKS${NC}"
echo -e "Warnings: ${YELLOW}$WARNINGS${NC}"
# Calculate success rate
if [ "$TOTAL_CHECKS" -gt 0 ]; then
SUCCESS_RATE=$(( (PASSED_CHECKS * 100) / TOTAL_CHECKS ))
echo "Success rate: ${SUCCESS_RATE}%"
echo ""
if [ "$SUCCESS_RATE" -ge 90 ]; then
echo -e "${GREEN}✓ VALIDATION PASSED - SDK is production ready!${NC}"
exit 0
elif [ "$SUCCESS_RATE" -ge 70 ]; then
echo -e "${YELLOW}⚠ VALIDATION PARTIAL - SDK needs minor improvements${NC}"
exit 1
else
echo -e "${RED}✗ VALIDATION FAILED - SDK needs significant work${NC}"
exit 2
fi
fi
echo ""
echo "Validation complete."