diff --git a/test/IdentityKeyStore_test.js b/test/IdentityKeyStore_test.js index 45c1724..01b8e5a 100644 --- a/test/IdentityKeyStore_test.js +++ b/test/IdentityKeyStore_test.js @@ -1,6 +1,7 @@ function testIdentityKeyStore(store, registrationId, identityKey) { describe('IdentityKeyStore', function() { var number = '+5558675309'; + var address = new libsignal.SignalProtocolAddress('+5558675309', 1); var testKey; before(function(done) { Internal.crypto.createKeyPair().then(function(keyPair) { @@ -25,7 +26,7 @@ function testIdentityKeyStore(store, registrationId, identityKey) { }); describe('saveIdentity', function() { it('stores identity keys', function(done) { - store.saveIdentity(number, testKey.pubKey).then(function() { + store.saveIdentity(address.toString(), testKey.pubKey).then(function() { return store.loadIdentityKey(number).then(function(key) { assertEqualArrayBuffers(key, testKey.pubKey); }); @@ -34,7 +35,7 @@ function testIdentityKeyStore(store, registrationId, identityKey) { }); describe('isTrustedIdentity', function() { it('returns true if a key is trusted', function(done) { - store.saveIdentity(number, testKey.pubKey).then(function() { + store.saveIdentity(address.toString(), testKey.pubKey).then(function() { store.isTrustedIdentity(number, testKey.pubKey).then(function(trusted) { if (trusted) { done(); @@ -46,7 +47,7 @@ function testIdentityKeyStore(store, registrationId, identityKey) { }); it('returns false if a key is untrusted', function(done) { var newIdentity = libsignal.crypto.getRandomBytes(33); - store.saveIdentity(number, testKey.pubKey).then(function() { + store.saveIdentity(address.toString(), testKey.pubKey).then(function() { store.isTrustedIdentity(number, newIdentity).then(function(trusted) { if (trusted) { done(new Error('Wrong value for untrusted key')); diff --git a/test/InMemorySignalProtocolStore.js b/test/InMemorySignalProtocolStore.js index 17c874c..edd4313 100644 --- a/test/InMemorySignalProtocolStore.js +++ b/test/InMemorySignalProtocolStore.js @@ -56,8 +56,10 @@ SignalProtocolStore.prototype = { if (identifier === null || identifier === undefined) throw new Error("Tried to put identity key for undefined/null key"); - var existing = this.get('identityKey' + identifier); - this.put('identityKey' + identifier, identityKey) + var address = new libsignal.SignalProtocolAddress.fromString(identifier); + + var existing = this.get('identityKey' + address.getName()); + this.put('identityKey' + address.getName(), identityKey) if (existing && util.toString(identityKey) !== util.toString(existing)) { return Promise.resolve(true); diff --git a/test/SessionCipherTest.js b/test/SessionCipherTest.js index 621f695..6ac8965 100644 --- a/test/SessionCipherTest.js +++ b/test/SessionCipherTest.js @@ -408,7 +408,7 @@ describe('SessionCipher', function() { }).then(function() { return generateIdentity(bobStore); }).then(function() { - return aliceStore.saveIdentity(BOB_ADDRESS.getName(), bobStore.get('identityKey').pubKey); + return aliceStore.saveIdentity(BOB_ADDRESS.toString(), bobStore.get('identityKey').pubKey); }).then(function() { done(); });