As the protocol becomes more complex we are having timing issues within out end to end tests creep in.
we need to fastforward in sync with blockchain time.
We should do this by:
Making all "waits" dependent on blocks received from whatever chain we are listening to.
This means listening to each block and processing the block extracting the timestamp and considering that the timestamp to react to within the protocol.
Eg
test('full e2e with blockchain time travel', async ({ page }) => {
// 1. Mock browser time
await page.clock.install({ time: Date.now() });
await page.goto('http://localhost:3000');
// 2. Advance blockchain time (via test RPC)
await page.evaluate(async () => {
await window.ethereum.request({
method: 'evm_increaseTime',
params: [3600]
});
await window.ethereum.request({ method: 'evm_mine' });
});
// 3. Advance browser time to match
await page.clock.fastForward(3600000); // Should probably not be required
// Now both client and blockchain are synchronized in the future
await page.click('#check-status');
await expect(page.locator('#result')).toContainText('ready');
});
We should ensure all components synchronize with block advancement to make end to end tests run more quickly.
As the protocol becomes more complex we are having timing issues within out end to end tests creep in.
we need to fastforward in sync with blockchain time.
We should do this by:
Making all "waits" dependent on blocks received from whatever chain we are listening to.
This means listening to each block and processing the block extracting the timestamp and considering that the timestamp to react to within the protocol.
Eg
We should ensure all components synchronize with block advancement to make end to end tests run more quickly.