add performance test
This commit is contained in:
parent
47d86825e2
commit
49ac4e6816
|
@ -18,16 +18,23 @@ describe('Basic', function() {
|
|||
var info = '\npassphrase: ' + passphrase + '\n' + 'userid: ' + userid + '\n' + 'message: ' + message;
|
||||
|
||||
var privKeys = openpgp.key.readArmored(key.privateKeyArmored);
|
||||
var publicKeys = openpgp.key.readArmored(key.publicKeyArmored);
|
||||
|
||||
expect(privKeys).to.exist;
|
||||
expect(privKeys.err).to.not.exist;
|
||||
expect(privKeys.keys).to.have.length(1);
|
||||
|
||||
var privKey = privKeys.keys[0];
|
||||
var pubKey = publicKeys.keys[0];
|
||||
|
||||
expect(privKey).to.exist;
|
||||
expect(pubKey).to.exist;
|
||||
|
||||
var encrypted = openpgp.encryptMessage([privKey], message);
|
||||
var success = privKey.decrypt(passphrase);
|
||||
|
||||
expect(success).to.be.true;
|
||||
|
||||
var encrypted = openpgp.signAndEncryptMessage([pubKey], privKey, message);
|
||||
|
||||
expect(encrypted).to.exist;
|
||||
|
||||
|
@ -39,13 +46,10 @@ describe('Basic', function() {
|
|||
|
||||
expect(keyids).to.exist;
|
||||
|
||||
var success = privKey.decryptKeyPacket(keyids, passphrase);
|
||||
|
||||
expect(success).to.be.true;
|
||||
|
||||
var decrypted = openpgp.decryptMessage(privKey, msg);
|
||||
var decrypted = openpgp.decryptAndVerifyMessage(privKey, [pubKey], msg);
|
||||
expect(decrypted).to.exist;
|
||||
expect(decrypted).to.equal(message);
|
||||
expect(decrypted.signatures[0].valid).to.be.true;
|
||||
expect(decrypted.text).to.equal(message);
|
||||
};
|
||||
|
||||
it('ASCII Text', function (done) {
|
||||
|
@ -56,6 +60,26 @@ describe('Basic', function() {
|
|||
testHelper('●●●●', '♔♔♔♔ <test@example.com>', 'łäóć');
|
||||
done();
|
||||
});
|
||||
it('Performance test', function (done) {
|
||||
function randomString(length, chars) {
|
||||
var result = '';
|
||||
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
|
||||
return result;
|
||||
}
|
||||
var rString = randomString(1024*1024, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
|
||||
if (console.profile) {
|
||||
console.profile("encrypt/sign/verify/decrypt");
|
||||
}
|
||||
|
||||
testHelper('password', 'Test McTestington <test@example.com>', rString);
|
||||
|
||||
if (console.profileEnd) {
|
||||
console.profileEnd();
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Message encryption/decryption", function() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user