Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit f308236

Browse files
committed
Fix tests
Update in-memory storage implementation to parse full address strings in saveIdentity. Update usage of saveIdentity, passing in the full address string.
1 parent 1fe18c3 commit f308236

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

test/IdentityKeyStore_test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function testIdentityKeyStore(store, registrationId, identityKey) {
22
describe('IdentityKeyStore', function() {
33
var number = '+5558675309';
4+
var address = new libsignal.SignalProtocolAddress('+5558675309', 1);
45
var testKey;
56
before(function(done) {
67
Internal.crypto.createKeyPair().then(function(keyPair) {
@@ -25,7 +26,7 @@ function testIdentityKeyStore(store, registrationId, identityKey) {
2526
});
2627
describe('saveIdentity', function() {
2728
it('stores identity keys', function(done) {
28-
store.saveIdentity(number, testKey.pubKey).then(function() {
29+
store.saveIdentity(address.toString(), testKey.pubKey).then(function() {
2930
return store.loadIdentityKey(number).then(function(key) {
3031
assertEqualArrayBuffers(key, testKey.pubKey);
3132
});
@@ -34,7 +35,7 @@ function testIdentityKeyStore(store, registrationId, identityKey) {
3435
});
3536
describe('isTrustedIdentity', function() {
3637
it('returns true if a key is trusted', function(done) {
37-
store.saveIdentity(number, testKey.pubKey).then(function() {
38+
store.saveIdentity(address.toString(), testKey.pubKey).then(function() {
3839
store.isTrustedIdentity(number, testKey.pubKey).then(function(trusted) {
3940
if (trusted) {
4041
done();
@@ -46,7 +47,7 @@ function testIdentityKeyStore(store, registrationId, identityKey) {
4647
});
4748
it('returns false if a key is untrusted', function(done) {
4849
var newIdentity = libsignal.crypto.getRandomBytes(33);
49-
store.saveIdentity(number, testKey.pubKey).then(function() {
50+
store.saveIdentity(address.toString(), testKey.pubKey).then(function() {
5051
store.isTrustedIdentity(number, newIdentity).then(function(trusted) {
5152
if (trusted) {
5253
done(new Error('Wrong value for untrusted key'));

test/InMemorySignalProtocolStore.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ SignalProtocolStore.prototype = {
5656
if (identifier === null || identifier === undefined)
5757
throw new Error("Tried to put identity key for undefined/null key");
5858

59-
var existing = this.get('identityKey' + identifier);
60-
this.put('identityKey' + identifier, identityKey)
59+
var address = new libsignal.SignalProtocolAddress.fromString(identifier);
60+
61+
var existing = this.get('identityKey' + address.getName());
62+
this.put('identityKey' + address.getName(), identityKey)
6163

6264
if (existing && util.toString(identityKey) !== util.toString(existing)) {
6365
return Promise.resolve(true);

test/SessionCipherTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ describe('SessionCipher', function() {
408408
}).then(function() {
409409
return generateIdentity(bobStore);
410410
}).then(function() {
411-
return aliceStore.saveIdentity(BOB_ADDRESS.getName(), bobStore.get('identityKey').pubKey);
411+
return aliceStore.saveIdentity(BOB_ADDRESS.toString(), bobStore.get('identityKey').pubKey);
412412
}).then(function() {
413413
done();
414414
});

0 commit comments

Comments
 (0)