Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding automated anvil testing client creation. #324

Merged
merged 3 commits into from
Nov 8, 2023

Conversation

iainnash
Copy link
Collaborator

@iainnash iainnash commented Nov 3, 2023

Adding automated anvil test running using vitest for premint sdk testing.

Copy link
Collaborator

@oveddan oveddan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome discovery of how to get this to work, minor suggestions with naming and configuration

@@ -135,6 +135,10 @@ jobs:
run: |
npx turbo run build

- name: Test js package
run: |
npx turbo run test:js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

transport: http(anvilHost),
});

await use({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great use of use

afterEach(() => testClient.reset());

it(
anvilTest(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about renaming to anvilRunningTest

"--fork-url",
"https://rpc.zora.co/",
"--fork-block-number",
"6133407",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about allowing chain name (zora, or zora-sepolia) and blockNumber to be specified as arguments with defaults?

@iainnash
Copy link
Collaborator Author

iainnash commented Nov 3, 2023 via email

@oveddan
Copy link
Collaborator

oveddan commented Nov 3, 2023

from env vars or?

On Fri, Nov 3, 2023 at 17:20 Dan Oved @.> wrote: @.* approved this pull request. awesome discovery of how to get this to work, minor suggestions with naming and configuration ------------------------------ In .github/workflows/foundry.yml <#324 (comment)> : > @@ -135,6 +135,10 @@ jobs: run: | npx turbo run build + - name: Test js package + run: | + npx turbo run test:js nice! ------------------------------ In packages/protocol-sdk/src/anvil.ts <#324 (comment)> : > + chain, + transport: http(anvilHost), + }); + + const testClient = createTestClient({ + chain, + mode: "anvil", + transport: http(anvilHost), + }); + + const publicClient = createPublicClient({ + chain, + transport: http(anvilHost), + }); + + await use({ great use of use ------------------------------ In packages/protocol-sdk/src/create/1155-create-helper.test.ts <#324 (comment)> : > const demoTokenMetadataURI = "ipfs://DUMMY/token.json"; const demoContractMetadataURI = "ipfs://DUMMY/contract.json"; describe("create-helper", () => { - beforeEach(async () => { - await testClient.setBalance({ - address: creatorAccount, - value: parseEther("1"), - }); - }); - afterEach(() => testClient.reset()); - - it( + anvilTest( how about renaming to anvilRunningTest ------------------------------ In packages/protocol-sdk/src/anvil.ts <#324 (comment)> : > + }); +} + +export const anvilTest = test.extend({ + 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", how about allowing chain name (zora, or zora-sepolia) and blockNumber to be specified as arguments with defaults? — Reply to this email directly, view it on GitHub <#324 (review)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGMCODM5IWX5U2K7ECKSETYCVN23AVCNFSM6AAAAAA635YKDGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMJTGU2DENZRGY . You are receiving this because you authored the thread.Message ID: @.***>

i would say for each test, to be able to config via json the fork chain name (or rpc url) and fork block #

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants