-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_commit.mjs
More file actions
41 lines (33 loc) · 1.22 KB
/
Copy pathtest_commit.mjs
File metadata and controls
41 lines (33 loc) · 1.22 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
import DHT from './index.js'
import crypto from 'crypto'
console.log('🔍 Testing storage WITHOUT commit...')
const client = new DHT({ ephemeral: true, bootstrap: ['localhost:10001'] })
await client.fullyBootstrapped()
const testData = Buffer.from('Test without commit')
const hash = crypto.createHash('sha256').update(testData).digest()
console.log('📝 Trying query without commit...')
const q = client.query({ target: hash, command: 0, value: testData })
let responses = 0
for await (const data of q) {
responses++
console.log('📨 Response:', responses, 'from:', data.from.host + ':' + data.from.port)
}
console.log('✅ Query completed with', responses, 'responses')
console.log('🔍 Now checking if any nodes actually stored it...')
// Try to retrieve
const getQuery = client.query({ target: hash, command: 0 })
let found = false
for await (const data of getQuery) {
if (data.value) {
console.log('📤 Found stored data:', data.value.toString())
found = true
break
}
}
if (!found) {
console.log('❌ No data stored (expected - no commit)')
} else {
console.log('🎉 Data was stored even without commit!')
}
console.log('🔍 This tells us if the issue is with commit phase or basic storage')
process.exit(0)