forked from Emanuel250YT/trustblock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-lighthouse.js
More file actions
59 lines (45 loc) · 1.96 KB
/
Copy pathtest-lighthouse.js
File metadata and controls
59 lines (45 loc) · 1.96 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
require('dotenv').config();
const LighthouseService = require('./src/services/lighthouseService');
async function testLighthouse() {
console.log('🧪 Probando integración con Lighthouse...');
try {
// Inicializar servicio
const lighthouse = new LighthouseService();
if (!lighthouse.isConfigured()) {
console.error('❌ Lighthouse no está configurado. Verifica LIGHTHOUSE_API_KEY.');
return;
}
console.log('✅ Lighthouse configurado correctamente');
// Probar upload de texto
console.log('\n📝 Probando upload de texto...');
const testNews = {
title: 'Noticia de prueba TrueBlock',
content: 'Esta es una noticia de prueba para verificar la integración con Lighthouse.',
author: 'Sistema TrueBlock',
timestamp: new Date().toISOString(),
category: 'test'
};
const uploadResult = await lighthouse.uploadNews(testNews, {
id: 'test_' + Date.now(),
title: testNews.title
});
console.log('📊 Resultado del upload:');
console.log(` Hash: ${uploadResult.hash}`);
console.log(` Tamaño: ${lighthouse.formatBytes(uploadResult.size)}`);
console.log(` URL Gateway: ${uploadResult.gateway_url}`);
console.log(` URL Lighthouse: ${uploadResult.lighthouse_url}`);
// Probar descarga
console.log('\n📥 Probando descarga del contenido...');
const downloadResult = await lighthouse.downloadContent(uploadResult.hash);
console.log('✅ Contenido descargado exitosamente:');
console.log(` Título: ${downloadResult.metadata.title}`);
console.log(` Tipo: ${downloadResult.metadata.type}`);
console.log(` Timestamp: ${downloadResult.metadata.timestamp}`);
console.log('\n🎉 ¡Prueba de Lighthouse completada exitosamente!');
console.log(`\n🔗 Puedes ver el archivo en: ${uploadResult.lighthouse_url}`);
} catch (error) {
console.error('❌ Error en la prueba de Lighthouse:', error.message);
}
}
// Ejecutar prueba
testLighthouse();