peerpigeon 1.0.4 โ 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -1
- package/dist/peerpigeon-browser.js +439 -6
- package/dist/peerpigeon-browser.js.map +3 -3
- package/docs/BINARY_IMPLEMENTATION_SUMMARY.md +304 -0
- package/docs/BINARY_MESSAGES.md +332 -0
- package/docs/STREAMING_API.md +542 -0
- package/docs/STREAMING_IMPLEMENTATION_SUMMARY.md +286 -0
- package/examples/binary-message-demo.html +496 -0
- package/examples/browser-2/EXPRESS_SOLUTION.md +183 -0
- package/examples/browser-2/ICE_DEBUG.md +171 -0
- package/examples/browser-2/IMPLEMENTATION.md +218 -0
- package/examples/browser-2/QUICK_START.md +149 -0
- package/examples/browser-2/README.md +303 -0
- package/examples/browser-2/dist/assets/index-Cck_6WJV.css +1 -0
- package/examples/browser-2/dist/assets/index-D8-cNlWQ.js +57 -0
- package/examples/browser-2/dist/index.html +32 -0
- package/examples/browser-2/dist/peerpigeon-browser.js +12483 -0
- package/examples/browser-2/index.html +2 -1
- package/examples/browser-2/package-lock.json +1276 -0
- package/examples/browser-2/package.json +5 -3
- package/examples/browser-2/public/peerpigeon-browser.js +12483 -0
- package/examples/browser-2/src/App.vue +7 -4
- package/examples/browser-2/src/components/CryptoView.vue +4 -4
- package/examples/browser-2/src/components/TestingView.vue +794 -0
- package/examples/browser-2/src/main.js +7 -1
- package/examples/browser-2/src/router.js +63 -0
- package/examples/browser-2/src/stores/peerpigeon.js +68 -7
- package/examples/browser-2/vite.config.js +15 -1
- package/examples/stream-file-transfer-demo.html +935 -0
- package/package.json +1 -1
- package/src/ConnectionManager.js +30 -0
- package/src/PeerConnection.js +409 -4
- package/src/PeerPigeonMesh.js +120 -1
- package/src/SignalingClient.js +12 -5
- package/src/browser-entry.js +5 -1
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="testing-view">
|
|
3
|
+
<div class="view-header">
|
|
4
|
+
<h2>๐งช PeerPigeon API Testing</h2>
|
|
5
|
+
<p>Comprehensive test suite for validating all PeerPigeon features</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<!-- Quick Test Controls -->
|
|
9
|
+
<div class="card">
|
|
10
|
+
<h3>โก Quick Tests</h3>
|
|
11
|
+
<div class="button-grid">
|
|
12
|
+
<button @click="validatePeerId" class="btn btn-primary">
|
|
13
|
+
๐ Validate Peer ID
|
|
14
|
+
</button>
|
|
15
|
+
<button @click="runPerformanceTest" class="btn btn-primary" :disabled="!store.isConnected">
|
|
16
|
+
๐ Performance Test
|
|
17
|
+
</button>
|
|
18
|
+
<button @click="runStressTest" class="btn btn-primary" :disabled="!store.isConnected">
|
|
19
|
+
โก Stress Test
|
|
20
|
+
</button>
|
|
21
|
+
<button @click="testInvalidPeer" class="btn btn-secondary">
|
|
22
|
+
โ Test Invalid Peer
|
|
23
|
+
</button>
|
|
24
|
+
<button @click="testMalformedMessage" class="btn btn-secondary">
|
|
25
|
+
โ ๏ธ Test Malformed Message
|
|
26
|
+
</button>
|
|
27
|
+
<button @click="testDHTLimits" class="btn btn-secondary" :disabled="!store.isConnected">
|
|
28
|
+
๐ Test DHT Limits
|
|
29
|
+
</button>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<!-- Test Configuration -->
|
|
34
|
+
<div class="card">
|
|
35
|
+
<h3>โ๏ธ Test Configuration</h3>
|
|
36
|
+
<div class="input-grid">
|
|
37
|
+
<div class="input-group">
|
|
38
|
+
<label for="test-peer-id">Test Peer ID:</label>
|
|
39
|
+
<input
|
|
40
|
+
id="test-peer-id"
|
|
41
|
+
v-model="testPeerId"
|
|
42
|
+
type="text"
|
|
43
|
+
placeholder="Enter peer ID to validate"
|
|
44
|
+
>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="input-group">
|
|
47
|
+
<label for="test-message-count">Message Count:</label>
|
|
48
|
+
<input
|
|
49
|
+
id="test-message-count"
|
|
50
|
+
v-model.number="testMessageCount"
|
|
51
|
+
type="number"
|
|
52
|
+
min="1"
|
|
53
|
+
max="1000"
|
|
54
|
+
>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="input-group">
|
|
57
|
+
<label for="test-message-size">Message Size (chars):</label>
|
|
58
|
+
<input
|
|
59
|
+
id="test-message-size"
|
|
60
|
+
v-model.number="testMessageSize"
|
|
61
|
+
type="number"
|
|
62
|
+
min="1"
|
|
63
|
+
max="10000"
|
|
64
|
+
>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<!-- Test Results -->
|
|
70
|
+
<div class="card">
|
|
71
|
+
<h3>๐ Test Results</h3>
|
|
72
|
+
<div class="test-results-header">
|
|
73
|
+
<button @click="clearTestResults" class="btn btn-tertiary">
|
|
74
|
+
๐๏ธ Clear Results
|
|
75
|
+
</button>
|
|
76
|
+
<button @click="exportTestResults" class="btn btn-tertiary">
|
|
77
|
+
๐ฅ Export Results
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="test-results" ref="testResultsContainer">
|
|
81
|
+
<div v-if="testResults.length === 0" class="empty-state">
|
|
82
|
+
No test results yet. Run a test to see results here.
|
|
83
|
+
</div>
|
|
84
|
+
<div
|
|
85
|
+
v-for="(result, index) in testResults"
|
|
86
|
+
:key="index"
|
|
87
|
+
class="test-result-item"
|
|
88
|
+
:class="result.status"
|
|
89
|
+
>
|
|
90
|
+
<div class="result-header">
|
|
91
|
+
<span class="result-icon">{{ getStatusIcon(result.status) }}</span>
|
|
92
|
+
<span class="result-name">{{ result.name }}</span>
|
|
93
|
+
<span class="result-time">{{ formatTime(result.timestamp) }}</span>
|
|
94
|
+
</div>
|
|
95
|
+
<div class="result-details">
|
|
96
|
+
<pre>{{ result.details }}</pre>
|
|
97
|
+
</div>
|
|
98
|
+
<div v-if="result.error" class="result-error">
|
|
99
|
+
<strong>Error:</strong> {{ result.error }}
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<!-- Utility Test Results -->
|
|
106
|
+
<div class="card">
|
|
107
|
+
<h3>๐ง Utility Results</h3>
|
|
108
|
+
<div class="utility-results" v-if="utilityResult">
|
|
109
|
+
<pre>{{ utilityResult }}</pre>
|
|
110
|
+
</div>
|
|
111
|
+
<div v-else class="empty-state">
|
|
112
|
+
Utility test results will appear here
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<!-- Performance Metrics -->
|
|
117
|
+
<div class="card">
|
|
118
|
+
<h3>๐ Performance Metrics</h3>
|
|
119
|
+
<div class="metrics-grid">
|
|
120
|
+
<div class="metric-item">
|
|
121
|
+
<span class="metric-label">Messages Sent:</span>
|
|
122
|
+
<span class="metric-value">{{ performanceMetrics.messagesSent }}</span>
|
|
123
|
+
</div>
|
|
124
|
+
<div class="metric-item">
|
|
125
|
+
<span class="metric-label">Messages Received:</span>
|
|
126
|
+
<span class="metric-value">{{ performanceMetrics.messagesReceived }}</span>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="metric-item">
|
|
129
|
+
<span class="metric-label">DHT Operations:</span>
|
|
130
|
+
<span class="metric-value">{{ performanceMetrics.dhtOperations }}</span>
|
|
131
|
+
</div>
|
|
132
|
+
<div class="metric-item">
|
|
133
|
+
<span class="metric-label">Test Duration:</span>
|
|
134
|
+
<span class="metric-value">{{ formatDuration(performanceMetrics.duration) }}</span>
|
|
135
|
+
</div>
|
|
136
|
+
<div class="metric-item">
|
|
137
|
+
<span class="metric-label">Success Rate:</span>
|
|
138
|
+
<span class="metric-value">{{ successRate }}%</span>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="metric-item">
|
|
141
|
+
<span class="metric-label">Avg Response Time:</span>
|
|
142
|
+
<span class="metric-value">{{ avgResponseTime }}ms</span>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
<button @click="resetMetrics" class="btn btn-tertiary">
|
|
146
|
+
๐ Reset Metrics
|
|
147
|
+
</button>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<!-- Export Options -->
|
|
151
|
+
<div class="card">
|
|
152
|
+
<h3>๐ Export Options</h3>
|
|
153
|
+
<div class="button-grid">
|
|
154
|
+
<button @click="exportLogs" class="btn btn-primary">
|
|
155
|
+
๐ Export All Logs
|
|
156
|
+
</button>
|
|
157
|
+
<button @click="exportTestResults" class="btn btn-primary">
|
|
158
|
+
๐ Export Test Results
|
|
159
|
+
</button>
|
|
160
|
+
<button @click="exportMetrics" class="btn btn-primary">
|
|
161
|
+
๐ Export Metrics
|
|
162
|
+
</button>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</template>
|
|
167
|
+
|
|
168
|
+
<script setup>
|
|
169
|
+
import { ref, computed, nextTick } from 'vue';
|
|
170
|
+
import { usePeerPigeonStore } from '../stores/peerpigeon.js';
|
|
171
|
+
|
|
172
|
+
const store = usePeerPigeonStore();
|
|
173
|
+
|
|
174
|
+
// Test configuration
|
|
175
|
+
const testPeerId = ref('');
|
|
176
|
+
const testMessageCount = ref(50);
|
|
177
|
+
const testMessageSize = ref(100);
|
|
178
|
+
|
|
179
|
+
// Test results
|
|
180
|
+
const testResults = ref([]);
|
|
181
|
+
const utilityResult = ref('');
|
|
182
|
+
|
|
183
|
+
// Performance metrics
|
|
184
|
+
const performanceMetrics = ref({
|
|
185
|
+
messagesSent: 0,
|
|
186
|
+
messagesReceived: 0,
|
|
187
|
+
dhtOperations: 0,
|
|
188
|
+
duration: 0,
|
|
189
|
+
testStartTime: null,
|
|
190
|
+
testEndTime: null,
|
|
191
|
+
responseTimes: []
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Computed
|
|
195
|
+
const successRate = computed(() => {
|
|
196
|
+
if (testResults.value.length === 0) return 0;
|
|
197
|
+
const successful = testResults.value.filter(r => r.status === 'success').length;
|
|
198
|
+
return ((successful / testResults.value.length) * 100).toFixed(1);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const avgResponseTime = computed(() => {
|
|
202
|
+
const times = performanceMetrics.value.responseTimes;
|
|
203
|
+
if (times.length === 0) return 0;
|
|
204
|
+
const sum = times.reduce((a, b) => a + b, 0);
|
|
205
|
+
return (sum / times.length).toFixed(2);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Test results container ref
|
|
209
|
+
const testResultsContainer = ref(null);
|
|
210
|
+
|
|
211
|
+
// Helper methods
|
|
212
|
+
const addTestResult = (name, details, status = 'info', error = null) => {
|
|
213
|
+
testResults.value.push({
|
|
214
|
+
name,
|
|
215
|
+
details,
|
|
216
|
+
status,
|
|
217
|
+
error,
|
|
218
|
+
timestamp: Date.now()
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Scroll to bottom
|
|
222
|
+
nextTick(() => {
|
|
223
|
+
if (testResultsContainer.value) {
|
|
224
|
+
testResultsContainer.value.scrollTop = testResultsContainer.value.scrollHeight;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const getStatusIcon = (status) => {
|
|
230
|
+
const icons = {
|
|
231
|
+
success: 'โ
',
|
|
232
|
+
error: 'โ',
|
|
233
|
+
warning: 'โ ๏ธ',
|
|
234
|
+
info: 'โน๏ธ'
|
|
235
|
+
};
|
|
236
|
+
return icons[status] || 'โน๏ธ';
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const formatTime = (timestamp) => {
|
|
240
|
+
return new Date(timestamp).toLocaleTimeString();
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const formatDuration = (ms) => {
|
|
244
|
+
if (ms < 1000) return `${ms}ms`;
|
|
245
|
+
return `${(ms / 1000).toFixed(2)}s`;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// Test methods
|
|
249
|
+
const validatePeerId = () => {
|
|
250
|
+
if (!testPeerId.value) {
|
|
251
|
+
addTestResult('Peer ID Validation', 'Please enter a peer ID to validate', 'warning');
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Simple validation - should be a non-empty string
|
|
256
|
+
const isValid = testPeerId.value.length >= 8;
|
|
257
|
+
|
|
258
|
+
const details = `
|
|
259
|
+
Peer ID: ${testPeerId.value}
|
|
260
|
+
Length: ${testPeerId.value.length} characters
|
|
261
|
+
Valid: ${isValid ? 'Yes' : 'No'}
|
|
262
|
+
Expected: At least 8 characters
|
|
263
|
+
`.trim();
|
|
264
|
+
|
|
265
|
+
utilityResult.value = details;
|
|
266
|
+
addTestResult('Peer ID Validation', details, isValid ? 'success' : 'error');
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const runPerformanceTest = async () => {
|
|
270
|
+
if (!store.mesh) {
|
|
271
|
+
addTestResult('Performance Test', 'Mesh not initialized', 'error');
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
addTestResult('Performance Test', `Starting test with ${testMessageCount.value} messages...`, 'info');
|
|
276
|
+
|
|
277
|
+
const testMessage = 'x'.repeat(testMessageSize.value);
|
|
278
|
+
const startTime = Date.now();
|
|
279
|
+
let successCount = 0;
|
|
280
|
+
let failCount = 0;
|
|
281
|
+
const responseTimes = [];
|
|
282
|
+
|
|
283
|
+
performanceMetrics.value.testStartTime = startTime;
|
|
284
|
+
|
|
285
|
+
for (let i = 0; i < testMessageCount.value; i++) {
|
|
286
|
+
const msgStartTime = Date.now();
|
|
287
|
+
try {
|
|
288
|
+
const messageId = await store.sendBroadcastMessage(`${testMessage} #${i + 1}`);
|
|
289
|
+
if (messageId) {
|
|
290
|
+
successCount++;
|
|
291
|
+
performanceMetrics.value.messagesSent++;
|
|
292
|
+
responseTimes.push(Date.now() - msgStartTime);
|
|
293
|
+
} else {
|
|
294
|
+
failCount++;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Small delay every 10 messages
|
|
298
|
+
if (i % 10 === 0 && i > 0) {
|
|
299
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
300
|
+
}
|
|
301
|
+
} catch (error) {
|
|
302
|
+
failCount++;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const endTime = Date.now();
|
|
307
|
+
const duration = endTime - startTime;
|
|
308
|
+
performanceMetrics.value.testEndTime = endTime;
|
|
309
|
+
performanceMetrics.value.duration = duration;
|
|
310
|
+
performanceMetrics.value.responseTimes = responseTimes;
|
|
311
|
+
|
|
312
|
+
const messagesPerSecond = ((successCount / duration) * 1000).toFixed(2);
|
|
313
|
+
|
|
314
|
+
const details = `
|
|
315
|
+
Duration: ${duration}ms
|
|
316
|
+
Success: ${successCount}/${testMessageCount.value}
|
|
317
|
+
Failed: ${failCount}
|
|
318
|
+
Rate: ${messagesPerSecond} msg/sec
|
|
319
|
+
Avg Response: ${avgResponseTime.value}ms
|
|
320
|
+
`.trim();
|
|
321
|
+
|
|
322
|
+
addTestResult(
|
|
323
|
+
'Performance Test',
|
|
324
|
+
details,
|
|
325
|
+
successCount > failCount ? 'success' : 'warning'
|
|
326
|
+
);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const runStressTest = async () => {
|
|
330
|
+
if (!store.mesh) {
|
|
331
|
+
addTestResult('Stress Test', 'Mesh not initialized', 'error');
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
addTestResult('Stress Test', 'Starting stress test...', 'info');
|
|
336
|
+
|
|
337
|
+
const operations = [];
|
|
338
|
+
const startTime = Date.now();
|
|
339
|
+
|
|
340
|
+
// DHT stress test
|
|
341
|
+
for (let i = 0; i < 20; i++) {
|
|
342
|
+
operations.push(
|
|
343
|
+
store.dhtPut(`stress-test-${i}`, { value: i, timestamp: Date.now() })
|
|
344
|
+
.then(() => {
|
|
345
|
+
performanceMetrics.value.dhtOperations++;
|
|
346
|
+
return { success: true };
|
|
347
|
+
})
|
|
348
|
+
.catch(err => ({ error: err.message }))
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Message stress test
|
|
353
|
+
for (let i = 0; i < 50; i++) {
|
|
354
|
+
try {
|
|
355
|
+
const messageId = await store.sendBroadcastMessage(`Stress test message #${i + 1}`);
|
|
356
|
+
if (messageId) {
|
|
357
|
+
performanceMetrics.value.messagesSent++;
|
|
358
|
+
operations.push(Promise.resolve({ success: true }));
|
|
359
|
+
} else {
|
|
360
|
+
operations.push(Promise.resolve({ error: 'Failed to send' }));
|
|
361
|
+
}
|
|
362
|
+
} catch (error) {
|
|
363
|
+
operations.push(Promise.resolve({ error: error.message }));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const results = await Promise.allSettled(operations);
|
|
368
|
+
const endTime = Date.now();
|
|
369
|
+
const duration = endTime - startTime;
|
|
370
|
+
|
|
371
|
+
const successful = results.filter(r =>
|
|
372
|
+
r.status === 'fulfilled' && r.value?.success
|
|
373
|
+
).length;
|
|
374
|
+
const failed = results.length - successful;
|
|
375
|
+
|
|
376
|
+
const details = `
|
|
377
|
+
Duration: ${duration}ms
|
|
378
|
+
Operations: ${results.length}
|
|
379
|
+
Successful: ${successful}
|
|
380
|
+
Failed: ${failed}
|
|
381
|
+
Success Rate: ${((successful / results.length) * 100).toFixed(1)}%
|
|
382
|
+
`.trim();
|
|
383
|
+
|
|
384
|
+
addTestResult(
|
|
385
|
+
'Stress Test',
|
|
386
|
+
details,
|
|
387
|
+
successful > failed ? 'success' : 'warning'
|
|
388
|
+
);
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
const testInvalidPeer = async () => {
|
|
392
|
+
const invalidPeerId = 'invalid-peer-id-12345';
|
|
393
|
+
|
|
394
|
+
try {
|
|
395
|
+
await store.sendDirectMessage(invalidPeerId, 'Test message');
|
|
396
|
+
addTestResult(
|
|
397
|
+
'Invalid Peer Test',
|
|
398
|
+
'Message sent to invalid peer (unexpected)',
|
|
399
|
+
'warning'
|
|
400
|
+
);
|
|
401
|
+
} catch (error) {
|
|
402
|
+
addTestResult(
|
|
403
|
+
'Invalid Peer Test',
|
|
404
|
+
`Handled gracefully: ${error.message}`,
|
|
405
|
+
'success'
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
const testMalformedMessage = async () => {
|
|
411
|
+
const malformedMessages = [
|
|
412
|
+
{ type: 'undefined', value: undefined },
|
|
413
|
+
{ type: 'null', value: null },
|
|
414
|
+
{ type: 'function', value: () => {} },
|
|
415
|
+
{ type: 'symbol', value: Symbol('test') }
|
|
416
|
+
];
|
|
417
|
+
|
|
418
|
+
const results = [];
|
|
419
|
+
|
|
420
|
+
for (const msg of malformedMessages) {
|
|
421
|
+
try {
|
|
422
|
+
const messageId = await store.sendBroadcast(msg.value);
|
|
423
|
+
results.push(`${msg.type}: ${messageId ? 'Sent' : 'Failed'}`);
|
|
424
|
+
} catch (error) {
|
|
425
|
+
results.push(`${msg.type}: Error handled - ${error.message}`);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
addTestResult(
|
|
430
|
+
'Malformed Message Test',
|
|
431
|
+
results.join('\n'),
|
|
432
|
+
'success'
|
|
433
|
+
);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const testDHTLimits = async () => {
|
|
437
|
+
try {
|
|
438
|
+
// Test with large data
|
|
439
|
+
const largeData = 'x'.repeat(100000); // 100KB string
|
|
440
|
+
const startTime = Date.now();
|
|
441
|
+
|
|
442
|
+
await store.dhtPut('large-data-test', largeData);
|
|
443
|
+
const stored = await store.dhtGet('large-data-test');
|
|
444
|
+
const endTime = Date.now();
|
|
445
|
+
|
|
446
|
+
const success = stored === largeData;
|
|
447
|
+
const details = `
|
|
448
|
+
Data size: 100KB
|
|
449
|
+
Duration: ${endTime - startTime}ms
|
|
450
|
+
Success: ${success}
|
|
451
|
+
`.trim();
|
|
452
|
+
|
|
453
|
+
addTestResult('DHT Limits Test', details, success ? 'success' : 'error');
|
|
454
|
+
} catch (error) {
|
|
455
|
+
addTestResult(
|
|
456
|
+
'DHT Limits Test',
|
|
457
|
+
`Limit enforced: ${error.message}`,
|
|
458
|
+
'success'
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// Export methods
|
|
464
|
+
const exportLogs = () => {
|
|
465
|
+
const logs = {
|
|
466
|
+
testResults: testResults.value,
|
|
467
|
+
performanceMetrics: performanceMetrics.value,
|
|
468
|
+
debugLogs: store.debugLogs,
|
|
469
|
+
messages: store.messages,
|
|
470
|
+
networkStatus: store.networkStatus,
|
|
471
|
+
timestamp: new Date().toISOString()
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
downloadJSON(logs, `peerpigeon-logs-${Date.now()}.json`);
|
|
475
|
+
addTestResult('Export', 'Logs exported successfully', 'success');
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
const exportTestResults = () => {
|
|
479
|
+
const data = {
|
|
480
|
+
results: testResults.value,
|
|
481
|
+
metrics: performanceMetrics.value,
|
|
482
|
+
successRate: successRate.value,
|
|
483
|
+
avgResponseTime: avgResponseTime.value,
|
|
484
|
+
timestamp: new Date().toISOString()
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
downloadJSON(data, `peerpigeon-test-results-${Date.now()}.json`);
|
|
488
|
+
addTestResult('Export', 'Test results exported successfully', 'success');
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
const exportMetrics = () => {
|
|
492
|
+
downloadJSON(
|
|
493
|
+
performanceMetrics.value,
|
|
494
|
+
`peerpigeon-metrics-${Date.now()}.json`
|
|
495
|
+
);
|
|
496
|
+
addTestResult('Export', 'Metrics exported successfully', 'success');
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
const downloadJSON = (data, filename) => {
|
|
500
|
+
const dataStr = JSON.stringify(data, null, 2);
|
|
501
|
+
const dataBlob = new Blob([dataStr], { type: 'application/json' });
|
|
502
|
+
const url = URL.createObjectURL(dataBlob);
|
|
503
|
+
|
|
504
|
+
const link = document.createElement('a');
|
|
505
|
+
link.href = url;
|
|
506
|
+
link.download = filename;
|
|
507
|
+
link.click();
|
|
508
|
+
|
|
509
|
+
URL.revokeObjectURL(url);
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
// Clear methods
|
|
513
|
+
const clearTestResults = () => {
|
|
514
|
+
testResults.value = [];
|
|
515
|
+
utilityResult.value = '';
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const resetMetrics = () => {
|
|
519
|
+
performanceMetrics.value = {
|
|
520
|
+
messagesSent: 0,
|
|
521
|
+
messagesReceived: 0,
|
|
522
|
+
dhtOperations: 0,
|
|
523
|
+
duration: 0,
|
|
524
|
+
testStartTime: null,
|
|
525
|
+
testEndTime: null,
|
|
526
|
+
responseTimes: []
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
</script>
|
|
530
|
+
|
|
531
|
+
<style scoped>
|
|
532
|
+
.testing-view {
|
|
533
|
+
display: flex;
|
|
534
|
+
flex-direction: column;
|
|
535
|
+
gap: 24px;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.view-header {
|
|
539
|
+
margin-bottom: 8px;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.view-header h2 {
|
|
543
|
+
font-size: 28px;
|
|
544
|
+
font-weight: 600;
|
|
545
|
+
color: #1f2937;
|
|
546
|
+
margin: 0 0 8px 0;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.view-header p {
|
|
550
|
+
color: #6b7280;
|
|
551
|
+
margin: 0;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.card {
|
|
555
|
+
background: white;
|
|
556
|
+
border-radius: 12px;
|
|
557
|
+
padding: 24px;
|
|
558
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.card h3 {
|
|
562
|
+
font-size: 18px;
|
|
563
|
+
font-weight: 600;
|
|
564
|
+
color: #1f2937;
|
|
565
|
+
margin: 0 0 16px 0;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.button-grid {
|
|
569
|
+
display: grid;
|
|
570
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
571
|
+
gap: 12px;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.input-grid {
|
|
575
|
+
display: grid;
|
|
576
|
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
577
|
+
gap: 16px;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.input-group {
|
|
581
|
+
display: flex;
|
|
582
|
+
flex-direction: column;
|
|
583
|
+
gap: 6px;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.input-group label {
|
|
587
|
+
font-size: 14px;
|
|
588
|
+
font-weight: 500;
|
|
589
|
+
color: #374151;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.input-group input {
|
|
593
|
+
padding: 8px 12px;
|
|
594
|
+
border: 1px solid #d1d5db;
|
|
595
|
+
border-radius: 6px;
|
|
596
|
+
font-size: 14px;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.input-group input:focus {
|
|
600
|
+
outline: none;
|
|
601
|
+
border-color: #3b82f6;
|
|
602
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.btn {
|
|
606
|
+
padding: 10px 16px;
|
|
607
|
+
border: none;
|
|
608
|
+
border-radius: 6px;
|
|
609
|
+
font-size: 14px;
|
|
610
|
+
font-weight: 500;
|
|
611
|
+
cursor: pointer;
|
|
612
|
+
transition: all 0.2s;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.btn:disabled {
|
|
616
|
+
opacity: 0.6;
|
|
617
|
+
cursor: not-allowed;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
.btn-primary {
|
|
621
|
+
background: #3b82f6;
|
|
622
|
+
color: white;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.btn-primary:hover:not(:disabled) {
|
|
626
|
+
background: #2563eb;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.btn-secondary {
|
|
630
|
+
background: #6b7280;
|
|
631
|
+
color: white;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.btn-secondary:hover:not(:disabled) {
|
|
635
|
+
background: #4b5563;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.btn-tertiary {
|
|
639
|
+
background: #e5e7eb;
|
|
640
|
+
color: #374151;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.btn-tertiary:hover:not(:disabled) {
|
|
644
|
+
background: #d1d5db;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.test-results-header {
|
|
648
|
+
display: flex;
|
|
649
|
+
gap: 12px;
|
|
650
|
+
margin-bottom: 16px;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.test-results {
|
|
654
|
+
max-height: 500px;
|
|
655
|
+
overflow-y: auto;
|
|
656
|
+
display: flex;
|
|
657
|
+
flex-direction: column;
|
|
658
|
+
gap: 12px;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.empty-state {
|
|
662
|
+
padding: 40px;
|
|
663
|
+
text-align: center;
|
|
664
|
+
color: #9ca3af;
|
|
665
|
+
font-style: italic;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
.test-result-item {
|
|
669
|
+
padding: 16px;
|
|
670
|
+
border-radius: 8px;
|
|
671
|
+
border: 1px solid #e5e7eb;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.test-result-item.success {
|
|
675
|
+
background: #f0fdf4;
|
|
676
|
+
border-color: #86efac;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
.test-result-item.error {
|
|
680
|
+
background: #fef2f2;
|
|
681
|
+
border-color: #fca5a5;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
.test-result-item.warning {
|
|
685
|
+
background: #fffbeb;
|
|
686
|
+
border-color: #fde68a;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.test-result-item.info {
|
|
690
|
+
background: #eff6ff;
|
|
691
|
+
border-color: #93c5fd;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.result-header {
|
|
695
|
+
display: flex;
|
|
696
|
+
align-items: center;
|
|
697
|
+
gap: 12px;
|
|
698
|
+
margin-bottom: 12px;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.result-icon {
|
|
702
|
+
font-size: 20px;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
.result-name {
|
|
706
|
+
font-weight: 600;
|
|
707
|
+
color: #1f2937;
|
|
708
|
+
flex: 1;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.result-time {
|
|
712
|
+
font-size: 12px;
|
|
713
|
+
color: #6b7280;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
.result-details {
|
|
717
|
+
margin-top: 8px;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.result-details pre {
|
|
721
|
+
margin: 0;
|
|
722
|
+
font-size: 13px;
|
|
723
|
+
white-space: pre-wrap;
|
|
724
|
+
color: #374151;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.result-error {
|
|
728
|
+
margin-top: 8px;
|
|
729
|
+
padding: 8px 12px;
|
|
730
|
+
background: rgba(239, 68, 68, 0.1);
|
|
731
|
+
border-radius: 6px;
|
|
732
|
+
font-size: 13px;
|
|
733
|
+
color: #dc2626;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.utility-results {
|
|
737
|
+
padding: 16px;
|
|
738
|
+
background: #f9fafb;
|
|
739
|
+
border-radius: 8px;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
.utility-results pre {
|
|
743
|
+
margin: 0;
|
|
744
|
+
font-size: 14px;
|
|
745
|
+
color: #374151;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.metrics-grid {
|
|
749
|
+
display: grid;
|
|
750
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
751
|
+
gap: 16px;
|
|
752
|
+
margin-bottom: 16px;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.metric-item {
|
|
756
|
+
padding: 16px;
|
|
757
|
+
background: #f9fafb;
|
|
758
|
+
border-radius: 8px;
|
|
759
|
+
display: flex;
|
|
760
|
+
flex-direction: column;
|
|
761
|
+
gap: 8px;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
.metric-label {
|
|
765
|
+
font-size: 13px;
|
|
766
|
+
color: #6b7280;
|
|
767
|
+
font-weight: 500;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.metric-value {
|
|
771
|
+
font-size: 24px;
|
|
772
|
+
font-weight: 700;
|
|
773
|
+
color: #1f2937;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/* Scrollbar styles */
|
|
777
|
+
.test-results::-webkit-scrollbar {
|
|
778
|
+
width: 8px;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.test-results::-webkit-scrollbar-track {
|
|
782
|
+
background: #f1f5f9;
|
|
783
|
+
border-radius: 4px;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
.test-results::-webkit-scrollbar-thumb {
|
|
787
|
+
background: #cbd5e1;
|
|
788
|
+
border-radius: 4px;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
.test-results::-webkit-scrollbar-thumb:hover {
|
|
792
|
+
background: #94a3b8;
|
|
793
|
+
}
|
|
794
|
+
</style>
|