-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding automated anvil testing client creation. (#324)
* Adding automated anvil testing client creation. * finalize all testing * fix build
- Loading branch information
Showing
22 changed files
with
718 additions
and
725 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { spawn } from "node:child_process"; | ||
import { join } from "path"; | ||
import { test } from "vitest"; | ||
import { | ||
PublicClient, | ||
TestClient, | ||
WalletClient, | ||
createPublicClient, | ||
createTestClient, | ||
createWalletClient, | ||
http, | ||
} from "viem"; | ||
import { foundry } from "viem/chains"; | ||
|
||
export interface AnvilViemClientsTest { | ||
viemClients: { | ||
walletClient: WalletClient; | ||
publicClient: PublicClient; | ||
testClient: TestClient; | ||
}; | ||
} | ||
|
||
async function waitForAnvilInit(anvil: any) { | ||
return new Promise((resolve) => { | ||
anvil.stdout.once("data", () => { | ||
resolve(true); | ||
}); | ||
}); | ||
} | ||
|
||
export const anvilTest = test.extend<AnvilViemClientsTest>({ | ||
viemClients: async ({task}, use) => { | ||
console.log('setting up clients for ', task.name); | ||
const port = Math.floor(Math.random() * 2000) + 4000; | ||
const anvil = spawn( | ||
"anvil", | ||
[ | ||
"--port", | ||
`${port}`, | ||
"--fork-url", | ||
"https://rpc.zora.co/", | ||
"--fork-block-number", | ||
"6133407", | ||
"--chain-id", | ||
"31337", | ||
], | ||
{ | ||
cwd: join(__dirname, ".."), | ||
killSignal: "SIGINT", | ||
}, | ||
); | ||
const anvilHost = `http://0.0.0.0:${port}`; | ||
await waitForAnvilInit(anvil); | ||
|
||
const chain = { | ||
...foundry, | ||
}; | ||
|
||
const walletClient = createWalletClient({ | ||
chain, | ||
transport: http(anvilHost), | ||
}); | ||
|
||
const testClient = createTestClient({ | ||
chain, | ||
mode: "anvil", | ||
transport: http(anvilHost), | ||
}); | ||
|
||
const publicClient = createPublicClient({ | ||
chain, | ||
transport: http(anvilHost), | ||
}); | ||
|
||
await use({ | ||
publicClient, | ||
walletClient, | ||
testClient, | ||
}); | ||
|
||
// clean up function, called once after all tests run | ||
anvil.kill("SIGINT"); | ||
}, | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/protocol-sdk/src/client-base.ts → ...ages/protocol-sdk/src/apis/client-base.ts
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,9 +1,9 @@ | ||
export * from "./premint-client"; | ||
export * from "./premint/premint-client"; | ||
|
||
export * from "./preminter"; | ||
export * from "./premint/preminter"; | ||
|
||
export * from "./premint-api-client"; | ||
export * from "./premint/premint-api-client"; | ||
|
||
export * from "./mint-api-client"; | ||
export * from "./mint/mint-api-client"; | ||
|
||
export * from "./1155-create-helper"; | ||
export * from "./create/1155-create-helper"; |
8 changes: 4 additions & 4 deletions
8
packages/protocol-sdk/src/mint-api-client.ts → .../protocol-sdk/src/mint/mint-api-client.ts
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
6 changes: 3 additions & 3 deletions
6
...es/protocol-sdk/src/premint-api-client.ts → ...col-sdk/src/premint/premint-api-client.ts
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
Oops, something went wrong.