Skip to content
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”, 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

Network tests & updates #692

Merged
merged 17 commits into from
Apr 7, 2022
Merged
Changes from 1 commit
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
56 changes: 56 additions & 0 deletions test/net-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';
pinheadmz marked this conversation as resolved.
Show resolved Hide resolved

const assert = require('bsert');
const Network = require('../lib/protocol/network');
const {lookup, resolve} = require('../lib/net/lookup');

const main = Network.get('main');

const notAHost = 'not-a-domain.not-a-domain';

describe('Lookup', function() {
it('should lookup seed', async () => {
for (const host of main.seeds) {
const addresses = await lookup(host);
assert(addresses.length > 0, 'addresses not found.');
}
});

it('should fail lookup', async () => {
let err;

try {
await lookup(notAHost);
} catch (e) {
err = e;
}

assert(err);
assert.strictEqual(err.message, 'No DNS results.');
});

it('should lookup seed', async () => {
this.timeout(10000);

for (const host of main.seeds) {
const addresses = await resolve(host);

assert(addresses.length > 0, 'addresses not found.');
}
});

it('should fail resolve', async () => {
let err;

try {
await resolve(notAHost);
} catch (e) {
err = e;
}

assert(err);
assert.strictEqual(err.message, `Query error: NXDOMAIN (${notAHost} A).`);

// TODO: Host that does not have A/AAAA records?
});
nodech marked this conversation as resolved.
Show resolved Hide resolved
});