mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-16 23:13:08 +00:00
61 lines
1.1 KiB
TypeScript
61 lines
1.1 KiB
TypeScript
import { argsToArray, bufToHex, defaultArgs, strToHex } from './nim_waku';
|
|
|
|
test('Correctly serialized arguments', () => {
|
|
const args = defaultArgs();
|
|
Object.assign(args, { portsShift: 42 });
|
|
|
|
const actual = argsToArray(args);
|
|
|
|
const expected = [
|
|
'--nat=none',
|
|
'--listen-address=127.0.0.1',
|
|
'--relay=true',
|
|
'--rpc=true',
|
|
'--rpc-admin=true',
|
|
'--ports-shift=42',
|
|
];
|
|
|
|
expect(actual).toEqual(expected);
|
|
});
|
|
|
|
test('Convert utf-8 string to hex', () => {
|
|
const str = 'This is an utf-8 string.';
|
|
const expected = '0x5468697320697320616e207574662d3820737472696e672e';
|
|
|
|
const actual = strToHex(str);
|
|
expect(actual).toEqual(expected);
|
|
});
|
|
|
|
test('Convert buffer to hex', () => {
|
|
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,
|
|
]);
|
|
const expected = '0x5468697320697320616e207574662d3820737472696e672e';
|
|
|
|
const actual = bufToHex(buf);
|
|
expect(actual).toEqual(expected);
|
|
});
|