Skip to content

Commit

Permalink
test(integration): Reuse snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
espendk committed Dec 16, 2023
1 parent 9a190a4 commit 5e27fd6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/util/test/mochaHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type hookInfo = {
arbitrager: account;
};
server?: serverType;
snapshotId?: string;
closeCurrentProxy?: () => Promise<void>;
};

Expand Down Expand Up @@ -106,7 +107,7 @@ export const mochaHooks = {
// making sure that last one is mined before snapshot is taken, anvil may snapshot too early otherwise
await tx.wait();
mgv.disconnect();
await hook.server.snapshot();
hook.snapshotId = await hook.server.snapshot();
},

async beforeEachImpl(hook: hookInfo) {
Expand Down Expand Up @@ -194,9 +195,7 @@ export const mochaHooks = {
// Note, this is updated on this global instance, so a test should never read it inside an non-awaited async request
hook.server.url = `http://${serverParams.host}:${currentProxyPort}`;

await hook.server.revert();
// revert removes the old snapshot, a new snapshot is therefore needed. https://github.com/foundry-rs/foundry/blob/6262fbec64021463fd403204039201983effa00d/evm/src/executor/fork/database.rs#L117
await hook.server.snapshot();
await hook.server.revert(hook.snapshotId);
}
},

Expand Down

0 comments on commit 5e27fd6

Please sign in to comment.