Add attachment support to mock tests

This commit is contained in:
trevor-signal 2024-08-01 20:06:52 -04:00 committed by GitHub
parent 6940c532ea
commit 9010245083
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 252 additions and 11 deletions

View file

@ -158,14 +158,17 @@ export class Bootstrap {
private privDesktop?: Device;
private storagePath?: string;
private backupPath?: string;
private cdn3Path: string;
private timestamp: number = Date.now() - durations.WEEK;
private lastApp?: App;
private readonly randomId = crypto.randomBytes(8).toString('hex');
constructor(options: BootstrapOptions = {}) {
this.cdn3Path = path.join(os.tmpdir(), 'mock-signal-cdn3-');
this.server = new Server({
// Limit number of storage read keys for easier testing
maxStorageReadKeys: MAX_STORAGE_READ_KEYS,
cdn3Path: this.cdn3Path,
});
this.options = {
@ -286,12 +289,9 @@ export class Bootstrap {
await Promise.race([
Promise.all([
this.storagePath
? fs.rm(this.storagePath, { recursive: true })
: Promise.resolve(),
this.backupPath
? fs.rm(this.backupPath, { recursive: true })
: Promise.resolve(),
...[this.storagePath, this.backupPath, this.cdn3Path].map(tmpPath =>
tmpPath ? fs.rm(tmpPath, { recursive: true }) : Promise.resolve()
),
this.server.close(),
this.lastApp?.close(),
]),
@ -649,6 +649,7 @@ export class Bootstrap {
cdn: {
'0': url,
'2': url,
'3': `${url}/cdn3`,
},
updatesEnabled: false,