-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: init testClients in network setup
- Loading branch information
Showing
7 changed files
with
107 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import { inject, test } from "vitest" | ||
import { type ChainConfigWithBundler, initChain } from "./test.utils" | ||
import { | ||
type FundedTestClients, | ||
type NetworkConfigWithBundler, | ||
initNetwork, | ||
toFundedTestClients | ||
} from "./test.utils" | ||
|
||
export const testWithBundler = test.extend<{ | ||
rpc: ChainConfigWithBundler | ||
export type NetworkConfigWithTestClients = NetworkConfigWithBundler & { | ||
fundedTestClients: FundedTestClients | ||
} | ||
|
||
export const aaTest = test.extend<{ | ||
config: NetworkConfigWithTestClients | ||
}>({ | ||
// biome-ignore lint/correctness/noEmptyPattern: Needed in vitest :/ | ||
rpc: async ({}, use) => { | ||
const testChain = await initChain() | ||
await use({ ...testChain }) | ||
config: async ({}, use) => { | ||
const testNetwork = await initNetwork() | ||
const fundedTestClients = await toFundedTestClients(testNetwork) | ||
await use({ ...testNetwork, fundedTestClients }) | ||
await Promise.all([ | ||
testChain.instance.stop(), | ||
testChain.bundlerInstance.stop() | ||
testNetwork.instance.stop(), | ||
testNetwork.bundlerInstance.stop() | ||
]) | ||
} | ||
}) | ||
|
||
export type TestFileNetworkType = "LOCAL" | "GLOBAL" | ||
export const toNetwork = async (networkType: TestFileNetworkType) => | ||
// @ts-ignore | ||
await (networkType === "GLOBAL" ? inject("globalNetwork") : initChain()) | ||
await (networkType === "GLOBAL" ? inject("globalNetwork") : initNetwork()) |