Move to websocket for requests to signal server
This commit is contained in:
parent
8449f343a6
commit
1c1d0e2da0
31 changed files with 1892 additions and 1336 deletions
|
@ -14,15 +14,9 @@ const fakeAPI = {
|
|||
getAvatar: fakeCall,
|
||||
getDevices: fakeCall,
|
||||
// getKeysForIdentifier : fakeCall,
|
||||
getMessageSocket: async () => ({
|
||||
on() {},
|
||||
removeListener() {},
|
||||
close() {},
|
||||
sendBytes() {},
|
||||
}),
|
||||
getMyKeys: fakeCall,
|
||||
getProfile: fakeCall,
|
||||
getProvisioningSocket: fakeCall,
|
||||
getProvisioningResource: fakeCall,
|
||||
putAttachment: fakeCall,
|
||||
registerKeys: fakeCall,
|
||||
requestVerificationSMS: fakeCall,
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
// Copyright 2017-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* global textsecure */
|
||||
|
||||
describe('createTaskWithTimeout', () => {
|
||||
it('resolves when promise resolves', () => {
|
||||
const task = () => Promise.resolve('hi!');
|
||||
const taskWithTimeout = textsecure.createTaskWithTimeout(task);
|
||||
|
||||
return taskWithTimeout().then(result => {
|
||||
assert.strictEqual(result, 'hi!');
|
||||
});
|
||||
});
|
||||
it('flows error from promise back', () => {
|
||||
const error = new Error('original');
|
||||
const task = () => Promise.reject(error);
|
||||
const taskWithTimeout = textsecure.createTaskWithTimeout(task);
|
||||
|
||||
return taskWithTimeout().catch(flowedError => {
|
||||
assert.strictEqual(error, flowedError);
|
||||
});
|
||||
});
|
||||
it('rejects if promise takes too long (this one logs error to console)', () => {
|
||||
let complete = false;
|
||||
const task = () =>
|
||||
new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
complete = true;
|
||||
resolve();
|
||||
}, 3000);
|
||||
});
|
||||
const taskWithTimeout = textsecure.createTaskWithTimeout(task, this.name, {
|
||||
timeout: 10,
|
||||
});
|
||||
|
||||
return taskWithTimeout().then(
|
||||
() => {
|
||||
throw new Error('it was not supposed to resolve!');
|
||||
},
|
||||
() => {
|
||||
assert.strictEqual(complete, false);
|
||||
}
|
||||
);
|
||||
});
|
||||
it('resolves if task returns something falsey', () => {
|
||||
const task = () => {};
|
||||
const taskWithTimeout = textsecure.createTaskWithTimeout(task);
|
||||
return taskWithTimeout();
|
||||
});
|
||||
it('resolves if task returns a non-promise', () => {
|
||||
const task = () => 'hi!';
|
||||
const taskWithTimeout = textsecure.createTaskWithTimeout(task);
|
||||
return taskWithTimeout().then(result => {
|
||||
assert.strictEqual(result, 'hi!');
|
||||
});
|
||||
});
|
||||
it('rejects if task throws (and does not log about taking too long)', () => {
|
||||
const error = new Error('Task is throwing!');
|
||||
const task = () => {
|
||||
throw error;
|
||||
};
|
||||
const taskWithTimeout = textsecure.createTaskWithTimeout(task, this.name, {
|
||||
timeout: 10,
|
||||
});
|
||||
return taskWithTimeout().then(
|
||||
() => {
|
||||
throw new Error('Overall task should reject!');
|
||||
},
|
||||
flowedError => {
|
||||
assert.strictEqual(flowedError, error);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue