OverviewFilesCommitsIssuesDocsReleasesPeers

hyperswarm-peer / test / run_self_announce_live.js

32 lines · javascript ref:
#!/usr/bin/env node
// Stands up a real JS DHT testnet and runs test_self_announce_live against it.
//
//   node run_self_announce_live.js
//
// The point is real RESPONDERS. test_self_announce.cpp has no DHT, so nothing
// answers an announce and every claim about the populated-holder path went
// untested. See docs/PARITY-hyperswarm.md §16.

const { spawn } = require('child_process')
const path = require('path')
const createTestnet = require('hyperdht/testnet')

const BIN = path.join(__dirname, 'test_self_announce_live')

async function main () {
  const testnet = await createTestnet(8, { teardown: () => {} })
  const bootstrap = testnet.bootstrap.map(b => `${b.host}:${b.port}`).join(',')
  console.log(`testnet up (${testnet.nodes.length} nodes): ${bootstrap}\n`)

  const code = await new Promise((resolve) => {
    const p = spawn(BIN, [bootstrap], { stdio: 'inherit' })
    p.on('exit', resolve)
  })

  await testnet.destroy()
  console.log(`\ntest_self_announce_live exit=${code}`)
  process.exit(code)
}

main().catch((err) => { console.error(err); process.exit(1) })