diff --git a/apps/laboratory/tests/shared/fixtures/w3m-wallet-fixture.ts b/apps/laboratory/tests/shared/fixtures/w3m-wallet-fixture.ts index 50910ba33f..dc32d30583 100644 --- a/apps/laboratory/tests/shared/fixtures/w3m-wallet-fixture.ts +++ b/apps/laboratory/tests/shared/fixtures/w3m-wallet-fixture.ts @@ -50,13 +50,48 @@ export const testConnectedMW = base.extend({ } else { timeStart('doActionAndWaitForNewPage') const page = await doActionAndWaitForNewPage(modalPage.clickWalletDeeplink(), context) + let pairingCreatedTime: Date | null = null + let verificationStartedTime: Date | null = null + page.on('console', msg => { + if (msg.text().indexOf('set') > -1 && msg.text().indexOf('core/pairing/pairing') > -1) { + pairingCreatedTime = new Date() + } + if (msg.text().indexOf('resolving attestation') > -1) { + verificationStartedTime = new Date() + } + if (msg.text().indexOf('session_proposal') > -1 && msg.text().indexOf('verifyContext') > -1) { + // For some reason this log is emitted twice; so only recording the time once + if (verificationStartedTime) { + const verificationEndedTime = new Date() + timingRecords.push({ + item: 'sessionProposalVerification', + timeMs: verificationEndedTime.getTime() - verificationStartedTime.getTime() + }) + verificationStartedTime = null + } + } + }) timeEnd('doActionAndWaitForNewPage') + const connectionInitiated = new Date() timeStart('new WalletPage') const walletPage = new WalletPage(page) timeEnd('new WalletPage') timeStart('walletPage.handleSessionProposal') await walletPage.handleSessionProposal(DEFAULT_SESSION_PARAMS) timeEnd('walletPage.handleSessionProposal') + const proposalReceived = new Date() + timingRecords.push({ + item: 'deeplinkReceiveSessionProposal', + timeMs: proposalReceived.getTime() - connectionInitiated.getTime() + }) + if (pairingCreatedTime) { + timingRecords.push({ + item: 'pairingReceiveSessionProposal', + timeMs: proposalReceived.getTime() - (pairingCreatedTime as Date).getTime() + }) + } else { + throw new Error('pairingCreatedTime not yet set') + } await use(walletPage) } },