mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-08 00:33:12 +00:00
Reorganize tests to ensure they all display under a section (#421)
This commit is contained in:
parent
d4e72af664
commit
c31972de02
@ -11,7 +11,7 @@ import { createKeypairFromPeerId } from './keypair';
|
||||
import { v4 } from './index';
|
||||
|
||||
describe('ENR', function () {
|
||||
describe('decodeTxt', () => {
|
||||
describe('Txt codec', () => {
|
||||
it('should encodeTxt and decodeTxt', async () => {
|
||||
const peerId = await PeerId.create({ keyType: 'secp256k1' });
|
||||
const enr = ENR.createFromPeerId(peerId);
|
||||
@ -117,7 +117,7 @@ describe('ENR', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('verify', () => {
|
||||
describe('Verify', () => {
|
||||
it('should throw error - no id', () => {
|
||||
try {
|
||||
const enr = new ENR({}, BigInt(0), Buffer.alloc(0));
|
||||
@ -233,7 +233,7 @@ describe('ENR', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Multiformats support', () => {
|
||||
describe('Multiaddr getters and setters', () => {
|
||||
let privateKey: Buffer;
|
||||
let record: ENR;
|
||||
|
||||
@ -299,21 +299,26 @@ describe('ENR', function () {
|
||||
expect(record.get('ip')).to.deep.equal(tuples1[0][1]);
|
||||
expect(record.get('tcp')).to.deep.equal(tuples1[1][1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('location multiaddr', async () => {
|
||||
describe('Location multiaddr', async () => {
|
||||
const ip4 = '127.0.0.1';
|
||||
const ip6 = '::1';
|
||||
const tcp = 8080;
|
||||
const udp = 8080;
|
||||
let peerId;
|
||||
let enr: ENR;
|
||||
|
||||
const peerId = await PeerId.create({ keyType: 'secp256k1' });
|
||||
const enr = ENR.createFromPeerId(peerId);
|
||||
before(async function () {
|
||||
peerId = await PeerId.create({ keyType: 'secp256k1' });
|
||||
enr = ENR.createFromPeerId(peerId);
|
||||
enr.ip = ip4;
|
||||
enr.ip6 = ip6;
|
||||
enr.tcp = tcp;
|
||||
enr.udp = udp;
|
||||
enr.tcp6 = tcp;
|
||||
enr.udp6 = udp;
|
||||
});
|
||||
|
||||
it('should properly create location multiaddrs - udp4', () => {
|
||||
expect(enr.getLocationMultiaddr('udp4')).to.deep.equal(
|
||||
@ -377,5 +382,4 @@ describe('ENR', function () {
|
||||
enr.ip6 = ip6;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -2,7 +2,8 @@ import { expect } from 'chai';
|
||||
|
||||
import { argsToArray, bufToHex, defaultArgs, strToHex } from './nim_waku';
|
||||
|
||||
it('Correctly serialized arguments', function () {
|
||||
describe('nim_waku', () => {
|
||||
it('Correctly serialized arguments', function () {
|
||||
const args = defaultArgs();
|
||||
Object.assign(args, { portsShift: 42 });
|
||||
|
||||
@ -19,17 +20,17 @@ it('Correctly serialized arguments', function () {
|
||||
];
|
||||
|
||||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert utf-8 string to hex', function () {
|
||||
it('Convert utf-8 string to hex', function () {
|
||||
const str = 'This is an utf-8 string.';
|
||||
const expected = '5468697320697320616e207574662d3820737472696e672e';
|
||||
|
||||
const actual = strToHex(str);
|
||||
expect(actual).deep.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert buffer to hex', function () {
|
||||
it('Convert buffer to hex', function () {
|
||||
const buf = Uint8Array.from([
|
||||
0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x75,
|
||||
0x74, 0x66, 0x2d, 0x38, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e,
|
||||
@ -38,4 +39,5 @@ it('Convert buffer to hex', function () {
|
||||
|
||||
const actual = bufToHex(buf);
|
||||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user