holepunchto / hyperdht

The DHT powering Hyperswarm
https://docs.holepunch.to
MIT License
323 stars 46 forks source link

Add test for single node network #117

Closed LuKks closed 4 months ago

LuKks commented 1 year ago

Depends on https://github.com/mafintosh/dht-rpc/pull/57

LuKks commented 1 year ago

Will leave here some invalid tests in case it's useful in the future. They're invalid because two nodes are required for pinging each other to get their own stable address back, etc. Although, some changes can be done to make it work but it's probably not intended anyway

Tests ```js test.skip('first persistent node with no host given', async function (t) { const bootstrap1 = new DHT({ bootstrap: [], ephemeral: false, firewalled: false }) await bootstrap1.ready() t.is(bootstrap1.address().host, '::') t.ok(await makeServerAndClient([{ host: localIP(), port: bootstrap1.address().port }])) t.absent(await makeServerAndClient([{ host: '127.0.0.1', port: bootstrap1.address().port }])) await bootstrap1.destroy() }) test.skip('first persistent node but binds to IPv6 localhost', async function (t) { // Note: anyway will not work due peer.id ipv4 encoding const bootstrap1 = new DHT({ bootstrap: [], ephemeral: false, firewalled: false, host: '::1' }) await bootstrap1.ready() t.is(bootstrap1.address().host, '::1') t.ok(await makeServerAndClient([{ host: '::1', port: bootstrap1.address().port }])) await bootstrap1.destroy() }) test.skip('first persistent node but binds to IPv4 localhost', async function (t) { const bootstrap1 = new DHT({ bootstrap: [], ephemeral: false, firewalled: false, host: '127.0.0.1' }) await bootstrap1.ready() t.is(bootstrap1.address().host, '127.0.0.1') t.ok(await makeServerAndClient([{ host: '127.0.0.1', port: bootstrap1.address().port }])) await bootstrap1.destroy() }) test.skip('first persistent node with no host given but binds to local host address', async function (t) { const bootstrap1 = new DHT({ bootstrap: [], ephemeral: false, firewalled: false, host: localIP() }) await bootstrap1.ready() t.is(bootstrap1.address().host, localIP()) t.ok(await makeServerAndClient([{ host: localIP(), port: bootstrap1.address().port }])) await bootstrap1.destroy() }) test.skip('ephemeral node enters persistent mode, and later goes back to ephemeral', async function (t) { // This should test when a node is adaptive and becomes persistent naturally // but then later goes back into 'ephemeral' mode (i.e. due sleep, etc) // Currently, hyperdht is not destroying the persistent class object when it goes back to eph }) ```
LuKks commented 1 year ago

Depends on https://github.com/mafintosh/dht-rpc/pull/58

mafintosh commented 4 months ago

Just cleaning up, reopen if relevant still