-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_validation.cpp
More file actions
149 lines (135 loc) · 4.13 KB
/
simple_validation.cpp
File metadata and controls
149 lines (135 loc) · 4.13 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
/**
* @file simple_validation.cpp
* @brief Simple validation for EpicChainCpp SDK
*/
#include <iostream>
#include <memory>
#include <vector>
#include <string>
// Core includes
#include <epicchaincpp/crypto/ec_key_pair.hpp>
#include <epicchaincpp/wallet/account.hpp>
#include <epicchaincpp/wallet/wallet.hpp>
#include <epicchaincpp/types/hash160.hpp>
#include <epicchaincpp/types/hash256.hpp>
#include <epicchaincpp/utils/hex.hpp>
using namespace epicchaincpp;
using namespace std;
int main() {
cout << "========================================" << endl;
cout << " EpicChainCpp SDK Production Validation " << endl;
cout << "========================================" << endl << endl;
int tests_passed = 0;
int tests_failed = 0;
// 1. Test EC Key Pair
cout << "1. EC Key Pair Creation: ";
try {
// Generate random private key
vector<uint8_t> privKey(32);
for (int i = 0; i < 32; i++) {
privKey[i] = rand() % 256;
}
auto keyPair = make_shared<ECKeyPair>(privKey);
if (keyPair != nullptr) {
cout << "✅ PASS" << endl;
tests_passed++;
} else {
cout << "❌ FAIL" << endl;
tests_failed++;
}
} catch (...) {
cout << "❌ FAIL (exception)" << endl;
tests_failed++;
}
// 2. Test Account
cout << "2. Account Creation: ";
try {
auto account = Account::create();
if (account != nullptr) {
cout << "✅ PASS" << endl;
tests_passed++;
} else {
cout << "❌ FAIL" << endl;
tests_failed++;
}
} catch (...) {
cout << "❌ FAIL (exception)" << endl;
tests_failed++;
}
// 3. Test Wallet
cout << "3. Wallet Creation: ";
try {
auto wallet = make_shared<Wallet>("TestWallet");
if (wallet != nullptr) {
cout << "✅ PASS" << endl;
tests_passed++;
} else {
cout << "❌ FAIL" << endl;
tests_failed++;
}
} catch (...) {
cout << "❌ FAIL (exception)" << endl;
tests_failed++;
}
// 4. Test Hash160
cout << "4. Hash160 Operations: ";
try {
Hash160 hash;
auto str = hash.toString();
if (str.length() == 40) { // 20 bytes = 40 hex chars
cout << "✅ PASS" << endl;
tests_passed++;
} else {
cout << "❌ FAIL" << endl;
tests_failed++;
}
} catch (...) {
cout << "❌ FAIL (exception)" << endl;
tests_failed++;
}
// 5. Test Hash256
cout << "5. Hash256 Operations: ";
try {
Hash256 hash;
auto str = hash.toString();
if (str.length() == 64) { // 32 bytes = 64 hex chars
cout << "✅ PASS" << endl;
tests_passed++;
} else {
cout << "❌ FAIL" << endl;
tests_failed++;
}
} catch (...) {
cout << "❌ FAIL (exception)" << endl;
tests_failed++;
}
// 6. Test Hex Utils
cout << "6. Hex Encoding: ";
try {
vector<uint8_t> data = {0x01, 0x02, 0x03};
auto hex = Hex::encode(data);
if (hex == "010203") {
cout << "✅ PASS" << endl;
tests_passed++;
} else {
cout << "❌ FAIL" << endl;
tests_failed++;
}
} catch (...) {
cout << "❌ FAIL (exception)" << endl;
tests_failed++;
}
// Summary
cout << "\n========================================" << endl;
cout << " RESULTS SUMMARY " << endl;
cout << "========================================" << endl;
cout << "Tests Passed: " << tests_passed << endl;
cout << "Tests Failed: " << tests_failed << endl;
cout << "Success Rate: " << (tests_passed * 100.0 / (tests_passed + tests_failed)) << "%" << endl;
if (tests_failed == 0) {
cout << "\n✅ SDK IS PRODUCTION READY ✅" << endl;
} else {
cout << "\n⚠️ " << tests_failed << " TESTS FAILED ⚠️" << endl;
}
return tests_failed > 0 ? 1 : 0;
}