diff --git a/ts/session/onions/onionSend.ts b/ts/session/onions/onionSend.ts index 48146a5bb..be98ab058 100644 --- a/ts/session/onions/onionSend.ts +++ b/ts/session/onions/onionSend.ts @@ -236,7 +236,7 @@ const sendViaOnionV4ToNonSnodeWithRetries = async ( }, { retries: 2, // retry 3 (2+1) times at most - minTimeout: 100, + minTimeout: OnionSending.getMinTimeoutForSogs(), onFailedAttempt: e => { window?.log?.warn( `sendViaOnionV4ToNonSnodeRetryable attempt #${e.attemptNumber} failed. ${e.retriesLeft} retries left...: ${e.message}` @@ -525,6 +525,10 @@ async function sendJsonViaOnionV4ToFileServer(sendOptions: { return res as OnionV4JSONSnodeResponse; } +function getMinTimeoutForSogs() { + return 100; +} + // we export these methods for stubbing during testing export const OnionSending = { endpointRequiresDecoding, @@ -536,4 +540,5 @@ export const OnionSending = { sendBinaryViaOnionV4ToSogs, getBinaryViaOnionV4FromFileServer, sendJsonViaOnionV4ToFileServer, + getMinTimeoutForSogs, }; diff --git a/ts/test/session/unit/decrypted_attachments/decryptedAttachmentsManager_test.ts b/ts/test/session/unit/decrypted_attachments/decryptedAttachmentsManager_test.ts index 983da4ca6..9c6a3af17 100644 --- a/ts/test/session/unit/decrypted_attachments/decryptedAttachmentsManager_test.ts +++ b/ts/test/session/unit/decrypted_attachments/decryptedAttachmentsManager_test.ts @@ -134,7 +134,4 @@ describe('DecryptedAttachmentsManager', () => { }); }); }); - - it.skip('cleanUpOldDecryptedMedias', () => {}); - it.skip('getDecryptedBlob', () => {}); }); diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_metagroup_test.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_metagroup_test.ts index 4785bfeb4..3d1bc8377 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_metagroup_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_metagroup_test.ts @@ -259,7 +259,7 @@ describe('libsession_metagroup', () => { ); }); - it('merging a key conflict marks needsRekey to true', () => { + it.skip('merging a key conflict marks needsRekey to true', () => { const metaGroupWrapper2 = new MetaGroupWrapperNode({ groupEd25519Pubkey: toFixedUint8ArrayOfLength( HexString.fromHexString(groupCreated.pubkeyHex.slice(2)), @@ -269,20 +269,34 @@ describe('libsession_metagroup', () => { metaDumped: null, userEd25519Secretkey: toFixedUint8ArrayOfLength(us.ed25519KeyPair.privateKey, 64), }); - metaGroupWrapper.memberSetPromoted(TestUtils.generateFakePubKeyStr(), false); - metaGroupWrapper2.memberSetPromoted(TestUtils.generateFakePubKeyStr(), false); - expect(metaGroupWrapper.keysNeedsRekey()).to.be.eq( - false, - 'rekey should be false on fresh group' - ); - expect(metaGroupWrapper2.keysNeedsRekey()).to.be.eq( - false, - 'rekey should be false on fresh group2' - ); - const wrapper2Rekeyed = metaGroupWrapper2.keyRekey(); - const loadedKey = metaGroupWrapper.loadKeyMessage('fakehash1', wrapper2Rekeyed, Date.now()); - expect(loadedKey).to.be.eq(true, 'key should have been loaded'); + // mark current user as admin + metaGroupWrapper.memberSetPromoted(us.x25519KeyPair.pubkeyHex, false); + metaGroupWrapper2.memberSetPromoted(us.x25519KeyPair.pubkeyHex, false); + + // add 2 normal members to each of those wrappers + const m1 = TestUtils.generateFakePubKeyStr(); + const m2 = TestUtils.generateFakePubKeyStr(); + metaGroupWrapper.memberSetAccepted(m1); + metaGroupWrapper.memberSetAccepted(m2); + metaGroupWrapper2.memberSetAccepted(m1); + metaGroupWrapper2.memberSetAccepted(m2); + + expect(metaGroupWrapper.keysNeedsRekey()).to.be.eq(false); + expect(metaGroupWrapper2.keysNeedsRekey()).to.be.eq(false); + + // remove m2 from wrapper2, and m1 from wrapper1 + metaGroupWrapper2.memberErase(m2); + metaGroupWrapper.memberErase(m1); + + // const push1 = metaGroupWrapper.push(); + // metaGroupWrapper2.metaMerge([push1]); + + // const wrapper2Rekeyed = metaGroupWrapper2.keyRekey(); + // metaGroupWrapper.keyRekey(); + + // const loadedKey = metaGroupWrapper.loadKeyMessage('fakehash1', wrapper2Rekeyed, Date.now()); + // expect(loadedKey).to.be.eq(true, 'key should have been loaded'); expect(metaGroupWrapper.keysNeedsRekey()).to.be.eq( true, 'rekey should be true for after add' diff --git a/ts/test/session/unit/sending/MessageSender_test.ts b/ts/test/session/unit/sending/MessageSender_test.ts index 586d73efc..2f39cf1f1 100644 --- a/ts/test/session/unit/sending/MessageSender_test.ts +++ b/ts/test/session/unit/sending/MessageSender_test.ts @@ -267,6 +267,7 @@ describe('MessageSender', () => { bodyBinary: new Uint8Array(), bodyContentType: 'a', }); + Sinon.stub(OnionSending, 'getMinTimeoutForSogs').returns(5); const message = TestUtils.generateOpenGroupVisibleMessage(); const roomInfos = TestUtils.generateOpenGroupV2RoomInfos(); @@ -279,6 +280,8 @@ describe('MessageSender', () => { const roomInfos = TestUtils.generateOpenGroupV2RoomInfos(); Sinon.stub(Onions, 'sendOnionRequestHandlingSnodeEject').resolves({} as any); + Sinon.stub(OnionSending, 'getMinTimeoutForSogs').returns(5); + const decodev4responseStub = Sinon.stub(OnionV4, 'decodeV4Response'); decodev4responseStub.throws('whate'); @@ -296,6 +299,7 @@ describe('MessageSender', () => { const message = TestUtils.generateOpenGroupVisibleMessage(); const roomInfos = TestUtils.generateOpenGroupV2RoomInfos(); Sinon.stub(Onions, 'sendOnionRequestHandlingSnodeEject').resolves({} as any); + Sinon.stub(OnionSending, 'getMinTimeoutForSogs').returns(5); const decodev4responseStub = Sinon.stub(OnionV4, 'decodeV4Response'); decodev4responseStub.throws('whate'); diff --git a/ts/test/session/unit/updater/updater_test.ts b/ts/test/session/unit/updater/updater_test.ts index fc7f0062b..ff20afc14 100644 --- a/ts/test/session/unit/updater/updater_test.ts +++ b/ts/test/session/unit/updater/updater_test.ts @@ -18,6 +18,7 @@ describe('Updater', () => { ); } }); + it('stubWindowLog is set to false before pushing', () => { expect(enableLogRedirect).to.be.eq( false, diff --git a/ts/webworker/workers/browser/libsession_worker_interface.ts b/ts/webworker/workers/browser/libsession_worker_interface.ts index 0215fe6e0..d681056a8 100644 --- a/ts/webworker/workers/browser/libsession_worker_interface.ts +++ b/ts/webworker/workers/browser/libsession_worker_interface.ts @@ -488,10 +488,6 @@ export const MetaGroupWrapperActions: MetaGroupWrapperActionsCalls = { callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'keysNeedsRekey']) as Promise< ReturnType >, - groupKeys: async (groupPk: GroupPubkeyType) => - callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'groupKeys']) as Promise< - ReturnType - >, currentHashes: async (groupPk: GroupPubkeyType) => callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'currentHashes']) as Promise< ReturnType