mirror of https://github.com/waku-org/js-waku.git
Remove dupe tests
This commit is contained in:
parent
6afecd9989
commit
302fc20243
|
@ -4,7 +4,7 @@ import fc from 'fast-check';
|
|||
import { WakuMessage } from '../../lib/waku_message';
|
||||
import { getPublicKey } from '../../lib/waku_message/version_1';
|
||||
|
||||
describe('Waku Message', function () {
|
||||
describe('Waku Message: Browser & Node', function () {
|
||||
it('Waku message round trip binary serialization [clear]', async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(fc.string(), async (s) => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import debug from 'debug';
|
||||
import fc from 'fast-check';
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: No types available
|
||||
import TCP from 'libp2p-tcp';
|
||||
|
@ -21,120 +20,7 @@ import { DefaultContentTopic, WakuMessage } from './index';
|
|||
|
||||
const dbg = debug('waku:test:message');
|
||||
|
||||
describe('Waku Message', function () {
|
||||
it('Waku message round trip binary serialization [clear]', async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(fc.string(), async (s) => {
|
||||
const msg = await WakuMessage.fromUtf8String(s);
|
||||
const binary = msg.encode();
|
||||
const actual = await WakuMessage.decode(binary);
|
||||
|
||||
expect(actual).to.deep.equal(msg);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('Payload to utf-8', async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(fc.string(), async (s) => {
|
||||
const msg = await WakuMessage.fromUtf8String(s);
|
||||
const utf8 = msg.payloadAsUtf8;
|
||||
|
||||
return utf8 === s;
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('Waku message round trip binary encryption [asymmetric, no signature]', async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 32, maxLength: 32 }),
|
||||
async (payload, privKey) => {
|
||||
const publicKey = getPublicKey(privKey);
|
||||
|
||||
const msg = await WakuMessage.fromBytes(payload, {
|
||||
encPublicKey: publicKey,
|
||||
});
|
||||
|
||||
const wireBytes = msg.encode();
|
||||
const actual = await WakuMessage.decode(wireBytes, [privKey]);
|
||||
|
||||
expect(actual?.payload).to.deep.equal(payload);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('Waku message round trip binary encryption [asymmetric, signature]', async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 32, maxLength: 32 }),
|
||||
fc.uint8Array({ minLength: 32, maxLength: 32 }),
|
||||
async (payload, sigPrivKey, encPrivKey) => {
|
||||
const sigPubKey = getPublicKey(sigPrivKey);
|
||||
const encPubKey = getPublicKey(encPrivKey);
|
||||
|
||||
const msg = await WakuMessage.fromBytes(payload, {
|
||||
encPublicKey: encPubKey,
|
||||
sigPrivKey: sigPrivKey,
|
||||
});
|
||||
|
||||
const wireBytes = msg.encode();
|
||||
const actual = await WakuMessage.decode(wireBytes, [encPrivKey]);
|
||||
|
||||
expect(actual?.payload).to.deep.equal(payload);
|
||||
expect(actual?.signaturePublicKey).to.deep.equal(sigPubKey);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('Waku message round trip binary encryption [symmetric, no signature]', async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 32, maxLength: 32 }),
|
||||
async (payload, key) => {
|
||||
const msg = await WakuMessage.fromBytes(payload, {
|
||||
symKey: key,
|
||||
});
|
||||
|
||||
const wireBytes = msg.encode();
|
||||
const actual = await WakuMessage.decode(wireBytes, [key]);
|
||||
|
||||
expect(actual?.payload).to.deep.equal(payload);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('Waku message round trip binary encryption [symmetric, signature]', async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 32, maxLength: 32 }),
|
||||
fc.uint8Array({ minLength: 32, maxLength: 32 }),
|
||||
async (payload, sigPrivKey, symKey) => {
|
||||
const sigPubKey = getPublicKey(sigPrivKey);
|
||||
|
||||
const msg = await WakuMessage.fromBytes(payload, {
|
||||
symKey: symKey,
|
||||
sigPrivKey: sigPrivKey,
|
||||
});
|
||||
|
||||
const wireBytes = msg.encode();
|
||||
const actual = await WakuMessage.decode(wireBytes, [symKey]);
|
||||
|
||||
expect(actual?.payload).to.deep.equal(payload);
|
||||
expect(actual?.signaturePublicKey).to.deep.equal(sigPubKey);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Waku Message: Node only', function () {
|
||||
describe('Interop: Nim', function () {
|
||||
let waku: Waku;
|
||||
let nimWaku: NimWaku;
|
||||
|
@ -178,9 +64,11 @@ describe('Interop: Nim', function () {
|
|||
|
||||
waku.relay.addDecryptionPrivateKey(privateKey);
|
||||
|
||||
const receivedMsgPromise: Promise<WakuMessage> = new Promise((resolve) => {
|
||||
const receivedMsgPromise: Promise<WakuMessage> = new Promise(
|
||||
(resolve) => {
|
||||
waku.relay.addObserver(resolve);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const publicKey = getPublicKey(privateKey);
|
||||
dbg('Post message');
|
||||
|
@ -218,3 +106,4 @@ describe('Interop: Nim', function () {
|
|||
expect(hexToBuf(msgs[0].payload).toString('utf-8')).to.equal(messageText);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue