chore: speed up unit testts

pull/3281/head
Audric Ackermann 3 months ago
parent dea69ed353
commit 7a4c0a0377
No known key found for this signature in database

@ -143,7 +143,7 @@ describe('OnionPaths', () => {
SNodeAPI.Onions.resetSnodeFailureCount(); SNodeAPI.Onions.resetSnodeFailureCount();
OnionPaths.resetPathFailureCount(); OnionPaths.resetPathFailureCount();
OnionPaths.clearTestOnionPath(); OnionPaths.clearTestOnionPath();
Sinon.stub(OnionPaths, 'getOnionPathMinTimeout').returns(10); Sinon.stub(OnionPaths, 'getOnionPathMinTimeout').returns(1);
}); });
afterEach(() => { afterEach(() => {
@ -157,6 +157,7 @@ describe('OnionPaths', () => {
}); });
it('throws if we cannot find a valid edge snode', async () => { it('throws if we cannot find a valid edge snode', async () => {
TestUtils.stubWindowLog();
const badPool = generateFakeSnodes(0).map(m => { const badPool = generateFakeSnodes(0).map(m => {
return { ...m, storage_server_version: [2, 1, 1] }; return { ...m, storage_server_version: [2, 1, 1] };
}); });

@ -216,7 +216,7 @@ describe('MessageQueue', () => {
done(e); done(e);
} }
} }
}); }, {interval:5});
}); });
}); });
}); });

@ -255,14 +255,14 @@ describe('JobRunner SINGLE', () => {
expect(runner.isRunningJobs()).to.be.eq(false); expect(runner.isRunningJobs()).to.be.eq(false);
runner.startProcessing(); // a job should be started right away in the list of jobs runner.startProcessing(); // a job should be started right away in the list of jobs
await sleepFor(100); await sleepFor(5);
expect(runner.isRunningJobs()).to.be.eq(true); expect(runner.isRunningJobs()).to.be.eq(true);
expect(runner.getCurrentJobs()).to.deep.eq([job.serializeJob()]); expect(runner.getCurrentJobs()).to.deep.eq([job.serializeJob()]);
clock.tick(5000); clock.tick(5000);
await sleepFor(10); await sleepFor(5);
const ret = await runner.stopAndWaitCurrentJobs(); const ret = await runner.stopAndWaitCurrentJobs();
expect(runner.getCurrentJobs()).to.deep.eq([]); expect(runner.getCurrentJobs()).to.deep.eq([]);
expect(runner.getScheduledJobs()).to.deep.eq([ expect(runner.getScheduledJobs()).to.deep.eq([
@ -412,6 +412,7 @@ describe('JobRunner MULTI', () => {
clock.tick(110); clock.tick(110);
// job should be started right away // job should be started right away
let result = await runnerMulti.addJob(job); let result = await runnerMulti.addJob(job);
expect(runnerMulti.getScheduledJobs()).to.deep.eq([job.serializeJob()]); expect(runnerMulti.getScheduledJobs()).to.deep.eq([job.serializeJob()]);
expect(result).to.eq('job_added'); expect(result).to.eq('job_added');
@ -420,7 +421,7 @@ describe('JobRunner MULTI', () => {
clock.tick(5010); clock.tick(5010);
// just give some time for the runner to pick up a new job // just give some time for the runner to pick up a new job
await sleepFor(100); await sleepFor(5);
const job2 = getFakeSleepForMultiJob({ timestamp: clock.now + 100 }); const job2 = getFakeSleepForMultiJob({ timestamp: clock.now + 100 });
@ -434,13 +435,16 @@ describe('JobRunner MULTI', () => {
clock.tick(100); clock.tick(100);
// that job2 should be running now // that job2 should be running now
await sleepFor(100); await sleepFor(5);
clock.tick(5000); clock.tick(5000);
await job2.waitForCurrentTry(); await job2.waitForCurrentTry();
clock.tick(730);
await runnerMulti.waitCurrentJobs(); await runnerMulti.waitCurrentJobs();
// we need to give some time for the jobrunner to handle the return of job2 and remove it // we need to give some time for the jobrunner to handle the return of job2 and remove it
await sleepFor(100); await sleepFor(5);
expect(runnerMulti.getScheduledJobs()).to.deep.eq([]); expect(runnerMulti.getScheduledJobs()).to.deep.eq([]);
}); });

Loading…
Cancel
Save