WIP III improve UX [snapshot task 2]
This commit is contained in:
1 parent
b2bab26981
commit
28c90d1d71
5 files changed
+97
-2
No files matched your search
@@ -71,3 +71,36 @@ test('event history remains bounded', () => {
|
||||
for (let i = 0; i < 100; i++) peer.dispatchEvent(new Event('iceconnectionstatechange'));
|
||||
assert.equal(diagnostics.lines.length, 80);
|
||||
});
|
||||
|
||||
|
||||
test('checking snapshots retain live pairs before failure removes them', async t => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const peer = new Peer();
|
||||
peer.connectionState = 'connecting'; peer.iceConnectionState = 'checking';
|
||||
let calls = 0;
|
||||
peer.getStats = async () => { calls++; return new Map([
|
||||
['pair', { type: 'candidate-pair', state: 'in-progress', requestsSent: 5, responsesReceived: 0 }],
|
||||
['transport', { type: 'transport', dtlsState: 'new', privateValue: 'secret' }],
|
||||
]); };
|
||||
const diagnostics = diagnose(peer);
|
||||
t.mock.timers.tick(3000);
|
||||
await Promise.resolve(); await Promise.resolve();
|
||||
assert.equal(calls, 1);
|
||||
assert.match(diagnostics.lines.join('\n'), /requestsSent=5.*responsesReceived=0/);
|
||||
assert.match(diagnostics.lines.join('\n'), /transport dtls=new/);
|
||||
assert.doesNotMatch(diagnostics.lines.join('\n'), /secret/);
|
||||
peer.iceConnectionState = 'failed';
|
||||
peer.dispatchEvent(new Event('iceconnectionstatechange'));
|
||||
peer.getStats = async () => { calls++; return new Map(); };
|
||||
await diagnostics.finish(() => { peer.closed = true; });
|
||||
t.mock.timers.tick(12000);
|
||||
assert.equal(calls, 2);
|
||||
assert.match(diagnostics.lines.join('\n'), /requestsSent=5/);
|
||||
assert.ok(diagnostics.lines.at(-1)?.endsWith('pairs=0'));
|
||||
});
|
||||
|
||||
test('DTLS diagnostics allowlist values and never retain transport details', () => {
|
||||
const lines = summarizeStats(new Map([['transport-secret', { type: 'transport', dtlsState: 'private-value', remoteCertificateId: 'secret' }]]));
|
||||
assert.ok(lines.includes('transport dtls=unknown'));
|
||||
assert.doesNotMatch(lines.join('\n'), /private|secret/);
|
||||
});
|
||||
Reference in new issue
Block a user