aboutsummaryrefslogtreecommitdiff
path: root/javascript/test/pk.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/test/pk.spec.js')
-rw-r--r--javascript/test/pk.spec.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/javascript/test/pk.spec.js b/javascript/test/pk.spec.js
index 9eec47e..aec90ac 100644
--- a/javascript/test/pk.spec.js
+++ b/javascript/test/pk.spec.js
@@ -61,4 +61,22 @@ describe("pk", function() {
console.log(TEST_TEXT, "->", decrypted);
expect(decrypted).toEqual(TEST_TEXT);
});
+
+ it('should pickle and unpickle', function () {
+ var TEST_TEXT = 'têst1';
+ var pubkey = decryption.generate_key();
+ encryption.set_recipient_key(pubkey);
+ var encrypted = encryption.encrypt(TEST_TEXT);
+
+ var PICKLE_KEY = 'secret_key';
+ var pickle = decryption.pickle(PICKLE_KEY);
+
+ var new_decryption = new Olm.PkDecryption();
+ var new_pubkey = new_decryption.unpickle(PICKLE_KEY, pickle);
+ expect(new_pubkey).toEqual(pubkey);
+ var decrypted = new_decryption.decrypt(encrypted.ephemeral, encrypted.mac, encrypted.ciphertext);
+ console.log(TEST_TEXT, "->", decrypted);
+ expect(decrypted).toEqual(TEST_TEXT);
+ new_decryption.free();
+ });
});