8000 test with real world dht by rafapaezbas · Pull Request #673 · holepunchto/pear · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test with real world dht #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, 8000 you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"sodium-native": "^4.1.1",
"streamx": "^2.16.1",
"tiny-byte-size": "^1.1.0",
"udx-native": "^1.8.9",
"udx-native": "^1.17.6",
"unix-path-resolve": "^1.0.2",
"url-file-url": "^1.0.2",
"watch-drive": "^2.0.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.mjs
8000
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const testnet = await createTestnet(10)
const dhtBootstrap = testnet.nodes.map(e => `${e.host}:${e.port}`).join(',')

const logging = Bare.argv.filter((arg) => arg.startsWith('--log'))
const tests = spawn(RUNTIME, [...logging, 'run', '--dht-bootstrap', dhtBootstrap, 'test'], { cwd: root, stdio: 'inherit' })
const tests = spawn(RUNTIME, [...logging, 'run', 'test'], { cwd: root, stdio: 'inherit' })

tests.on('exit', async (code) => {
await testnet.destroy()
Expand Down
58 changes: 29 additions & 29 deletions test/01-smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const entrypointAndFragment = path.join(Helper.localDir, 'test', 'fixtures', 'en

test('smoke', async function ({ ok, is, alike, plan, comment, teardown, timeout }) {
timeout(180000)
plan(14)
// plan(14)

const testVersions = async () => {
const dir = versionsDir
Expand Down Expand Up @@ -53,41 +53,41 @@ test('smoke', async function ({ ok, is, alike, plan, comment, teardown, timeout
ok(true, 'ended')
}

const testDhtBootstrap = async () => {
const dir = dhtBootstrapDir
// const testDhtBootstrap = async () => {
// const dir = dhtBootstrapDir

const helper = new Helper()
teardown(() => helper.close(), { order: Infinity })
await helper.ready()
// const helper = new Helper()
// teardown(() => helper.close(), { order: Infinity })
// await helper.ready()

const id = Math.floor(Math.random() * 10000)
// const id = Math.floor(Math.random() * 10000)

comment('staging')
const staging = helper.stage({ channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false })
teardown(() => Helper.teardownStream(staging))
const staged = await Helper.pick(staging, { tag: 'final' })
ok(staged.success, 'stage succeeded')
// comment('staging')
// const staging = helper.stage({ channel: `test-${id}`, name: `test-${id}`, dir, dryRun: false })
// teardown(() => Helper.teardownStream(staging))
// const staged = await Helper.pick(staging, { tag: 'final' })
// ok(staged.success, 'stage succeeded')

comment('seeding')
const seeding = helper.seed({ channel: `test-${id}`, name: `test-${id}`, dir, key: null, cmdArgs: [] })
teardown(() => Helper.teardownStream(seeding))
const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }])
const announced = await until.announced
ok(announced, 'seeding is announced')
// comment('seeding')
// const seeding = helper.seed({ channel: `test-${id}`, name: `test-${id}`, dir, key: null, cmdArgs: [] })
// teardown(() => Helper.teardownStream(seeding))
// const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }])
// const announced = await until.announced
// ok(announced, 'seeding is announced')

const key = await until.key
ok(hypercoreid.isValid(key), 'app key is valid')
// const key = await until.key
// ok(hypercoreid.isValid(key), 'app key is valid')

const link = `pear://${key}`
const run = await Helper.run({ link })
// const link = `pear://${key}`
// const run = await Helper.run({ link })

const result = await Helper.untilResult(run.pipe)
const dhtBootstrap = JSON.parse(result)
alike(dhtBootstrap, Pear.config.dht.bootstrap, 'dht bootstrap matches Pear.config.dht.bootstrap')
// const result = await Helper.untilResult(run.pipe)
// const dhtBootstrap = JSON.parse(result)
// alike(dhtBootstrap, Pear.config.dht.bootstrap, 'dht bootstrap matches Pear.config.dht.bootstrap')

await Helper.untilClose(run.pipe)
ok(true, 'ended')
}
// await Helper.untilClose(run.pipe)
// ok(true, 'ended')
// }

const testStorage = async () => {
const dir = storageDir
Expand Down Expand Up @@ -129,7 +129,7 @@ test('smoke', async function ({ ok, is, alike, plan, comment, teardown, timeout
ok(true, 'ended')
}

await Promise.all([testVersions(), testDhtBootstrap(), testStorage()])
await Promise.all([testVersions(), testStorage()])
})

test('app with assets', async function ({ ok, is, plan, comment, teardown, timeout }) {
Expand Down
4 changes: 2 additions & 2 deletions test/06-shutdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ test('sidecar should not spindown until ongoing update is finished', async (t) =

t.comment('3. Start sidecar and update using rcv-seeded key')
t.comment('\tStarting sidecar')
const dhtBootstrap = global.Pear.config.dht.bootstrap.map(e => `${e.host}:${e.port}`).join(',')
const sidecar = spawn(path.join(platformDirLs, 'current', BY_ARCH), ['--dht-bootstrap', dhtBootstrap, 'sidecar', '--key', staged.key], { stdio: 'pipe' })
// const dhtBootstrap = global.Pear.config.dht.bootstrap.map(e => `${e.host}:${e.port}`).join(',')
const sidecar = spawn(path.join(platformDirLs, 'current', BY_ARCH), ['sidecar', '--key', staged.key], { stdio: 'pipe' })
t.teardown(() => { if (sidecar.exitCode === null) sidecar?.kill() })
const untilExit = new Promise(resolve => sidecar.once('exit', resolve))
t.teardown(async () => untilExit, { order: Infinity })
Expand Down
5 changes: 3 additions & 2 deletions test/07-warmup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ test('staged bundle contains entries metadata', async function ({ ok, is, plan,
const key = await until.key
await until.announced

const swarm = new Hyperswarm({ bootstrap: Pear.config.dht.bootstrap })
const swarm = new Hyperswarm()
const tmpdir = await tmp()
const store = new Corestore(tmpdir)
await store.ready()
< 5D39 tool-tip id="tooltip-60d82087-3503-4cd0-9512-518473313d8b" for="expand-link-9-diff-bd2b0cb7a044469138af0cec75fe92c9de1ec937e8c0f036ce761957b325b088" popover="manual" data-direction="ne" data-type="label" data-view-component="true" class="sr-only position-absolute">Expand All @@ -128,8 +128,9 @@ test('staged bundle contains entries metadata', async function ({ ok, is, plan,
})

swarm.join(drive.discoveryKey)
await swarm.flush()

await new Promise((resolve) => setTimeout(resolve, 500))
await new Promise((resolve) => setTimeout(resolve, 2000))

comment('bundle entries should contain metadata')
for await (const file of drive.list()) {
Expand Down
4 changes: 2 additions & 2 deletions test/helper.js
6462
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class Helper extends IPC.Client {
const log = global.Pear.config.args.includes('--log')
const platformDir = opts.platformDir || PLATFORM_DIR
const runtime = path.join(platformDir, 'current', BY_ARCH)
const dhtBootstrap = Pear.config.dht.bootstrap.map(e => `${e.host}:${e.port}`).join(',')
const args = ['--sidecar', '--dht-bootstrap', dhtBootstrap]
// const dhtBootstrap = Pear.config.dht.bootstrap.map(e => `${e.host}:${e.port}`).join(',')
const args = ['--sidecar']
if (log) args.push('--log')
const pipeId = (s) => {
const buf = b4a.allocUnsafe(32)
Expand Down
Loading
0