pull/213/head
sachaaaaa 6 years ago
parent 16b96f3d21
commit ad5efc9ba3

@ -74,7 +74,7 @@ const fetch = async (url, options = {}) => {
} }
try { try {
result = JSON.parse(result); result = JSON.parse(result);
} catch(e) { } catch (e) {
log.warn(`Could not parse string to json ${result}`, e); log.warn(`Could not parse string to json ${result}`, e);
} }
} }

@ -98,8 +98,14 @@ describe('Snode Channel', () => {
senderPubKey, senderPubKey,
snodePrivKey snodePrivKey
); );
const encryptedArrayBuffer = dcodeIO.ByteBuffer.wrap(encrypted, 'base64').toArrayBuffer(); const encryptedArrayBuffer = dcodeIO.ByteBuffer.wrap(
const decrypted = await libloki.crypto.DHDecrypt(symmetricKey, encryptedArrayBuffer); encrypted,
'base64'
).toArrayBuffer();
const decrypted = await libloki.crypto.DHDecrypt(
symmetricKey,
encryptedArrayBuffer
);
const textDecoder = new TextDecoder(); const textDecoder = new TextDecoder();
const messageReceived = textDecoder.decode(decrypted); const messageReceived = textDecoder.decode(decrypted);
assert.strictEqual(messageSent, messageReceived); assert.strictEqual(messageSent, messageReceived);
@ -124,7 +130,9 @@ describe('Snode Channel', () => {
snodePrivKey snodePrivKey
); );
const encrypted = await libloki.crypto.DHEncrypt(symmetricKey, data); const encrypted = await libloki.crypto.DHEncrypt(symmetricKey, data);
const encryptedBase64 = dcodeIO.ByteBuffer.wrap(encrypted).toString('base64'); const encryptedBase64 = dcodeIO.ByteBuffer.wrap(encrypted).toString(
'base64'
);
// message received by Loki Messenger // message received by Loki Messenger
const decrypted = await channel.decrypt(snode.address, encryptedBase64); const decrypted = await channel.decrypt(snode.address, encryptedBase64);
assert.strictEqual(messageSent, decrypted); assert.strictEqual(messageSent, decrypted);

Loading…
Cancel
Save