Let the receiver fix a wrong salt during a search
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e47b55901
commit
aa61efcc10
3 files changed
+19
-18
No files matched your search
+13
-8
@@ -1180,7 +1180,7 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
|
||||
// The info_hash tells which salt a share took: the window its code ends with, or that and the own
|
||||
// salt, trimmed and NFC. A code made late in a window still lasts 6 minutes. The salt stays as it is
|
||||
// while a share or search runs.
|
||||
// while a share runs, a search lets it be fixed for the next Receive.
|
||||
test(`salt: ${name} a share takes the clock's salt or the own one, which stays while it runs`, async () => {
|
||||
const sender = await open(name);
|
||||
const hashes: string[] = [];
|
||||
@@ -1267,12 +1267,16 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
await sender.fill('#receive-code', 'abcdefghijk');
|
||||
await sender.click('#receive');
|
||||
await expect.poll(() => hashes).toContain(swarm('abcdefghijk', generated));
|
||||
await locked(true);
|
||||
await locked(false);
|
||||
await sender.fill('#salt', 'fixed');
|
||||
await sender.click('#receive');
|
||||
await expect.poll(() => hashes).toContain(swarm('abcdefghijk', 'fixed'));
|
||||
});
|
||||
});
|
||||
|
||||
// Until the transfer is over, on both sides.
|
||||
test(`salt: ${name} stays while the peers are connected`, async () => {
|
||||
// On the sender until the transfer is over. The receiver's search is over once connected, so its
|
||||
// salt can always change.
|
||||
test(`salt: ${name} stays on the sender while the peers are connected`, async () => {
|
||||
const tracker = await ownTracker();
|
||||
const [sender, receiver] = await Promise.all([open(name), open(name)]);
|
||||
for (const page of [sender, receiver]) {
|
||||
@@ -1282,9 +1286,9 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
await page.check('#own-salt');
|
||||
await page.fill('#salt', 'salt');
|
||||
}
|
||||
const locked = (disabled: boolean) =>
|
||||
const locked = (pages: Page[], disabled: boolean) =>
|
||||
Promise.all(
|
||||
[sender, receiver].flatMap((page) =>
|
||||
pages.flatMap((page) =>
|
||||
['#own-salt', '#salt', '#generate-salt'].map((id) =>
|
||||
expect(page.locator(id)).toBeEnabled({ enabled: !disabled }),
|
||||
),
|
||||
@@ -1295,14 +1299,15 @@ for (const name of Object.keys(BROWSERS)) {
|
||||
await connect('tracker', sender, receiver, await payload(randomBytes(1000)));
|
||||
await expect(sender.locator('#send-status')).toHaveText('Waiting for the receiver to download');
|
||||
await expect(receiver.locator('#receive-status')).toHaveText('Click Download to save the file');
|
||||
await locked(true);
|
||||
await locked([sender], true);
|
||||
await locked([receiver], false);
|
||||
|
||||
const started = downloadStarts(receiver);
|
||||
await receiver.click('#download');
|
||||
await started;
|
||||
await expect(sender.locator('#send-status')).toHaveText('Delivered');
|
||||
await expect(receiver.locator('#receive-status')).toHaveText('Download complete');
|
||||
await locked(false);
|
||||
await locked([sender, receiver], false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user