Skip to content

Commit dff3361

Browse files
committed
TestClient: allow OTKs and device keys to be uploaded at the same time
The rust backend uploads them together, so allow that to happen.
1 parent 71e51a0 commit dff3361

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spec/TestClient.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,30 @@ export class TestClient {
115115
}
116116

117117
/**
118-
* Set up expectations that the client will upload device keys.
118+
* Set up expectations that the client will upload device keys (and possibly one-time keys)
119119
*/
120120
public expectDeviceKeyUpload() {
121121
this.httpBackend
122122
.when("POST", "/keys/upload")
123123
.respond<IKeysUploadResponse, IUploadKeysRequest>(200, (_path, content) => {
124-
expect(content.one_time_keys).toBe(undefined);
125124
expect(content.device_keys).toBeTruthy();
126125

127126
logger.log(this + ": received device keys");
128127
// we expect this to happen before any one-time keys are uploaded.
129128
expect(Object.keys(this.oneTimeKeys!).length).toEqual(0);
130129

131130
this.deviceKeys = content.device_keys;
132-
return { one_time_key_counts: { signed_curve25519: 0 } };
131+
132+
// the first batch of one-time keys may be uploaded at the same time.
133+
if (content.one_time_keys) {
134+
logger.log(`${this}: received ${Object.keys(content.one_time_keys).length} one-time keys`);
135+
this.oneTimeKeys = content.one_time_keys;
136+
}
137+
return {
138+
one_time_key_counts: {
139+
signed_curve25519: Object.keys(this.oneTimeKeys!).length,
140+
},
141+
};
133142
});
134143
}
135144

0 commit comments

Comments
 (0)