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

Template improvements #5892

Merged
merged 8 commits into from
Oct 30, 2024
Merged

Template improvements #5892

merged 8 commits into from
Oct 30, 2024

Conversation

alcuadrado
Copy link
Member

This PR includes a first round of improvements to the template projects, it's still WIP, but can be merged as is.

@alcuadrado alcuadrado requested a review from kanej October 29, 2024 21:46
Copy link

changeset-bot bot commented Oct 29, 2024

⚠️ No Changeset found

Latest commit: 0edd1a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 29, 2024 9:52pm

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Oct 29, 2024
describe("Lock", function () {
let networkConnection: NetworkConnection<"l1">;
describe("Lock", async function () {
const { viem, networkHelpers } = await network.connect();
Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think about this async operation in the describe? @kanej @galargh

It makes the tests way simpler.

Copy link
Member

Choose a reason for hiding this comment

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

I think it cleans up the code. But I do find it surprising - I expect resource initialization code to be in the before/beforeEach.

I was initially concerned that this code might get run even if the describe is skipped, but I can confirm that isn't the case.

Would we use a similar pattern in the mocha template?

Copy link
Member Author

Choose a reason for hiding this comment

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

mocha intentionally doesn't support that. So we can't do it there.

Maybe we can initialize the network connection on the first provider call? I think the code style improvement is massive.

Copy link
Member Author

Choose a reason for hiding this comment

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

In reality, given that this is ESM, these calls can be in the top-level of the file.


describe("Lock", function () {
let networkConnection: NetworkConnection<"l1">;
let networkHelpers: any; // TODO: We need to export this type in @ignored/hardhat-vnext-network-helpers
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to export the NetworkHelpers as an interface in the plugin. It's now a class, but it should be a quick conversation into an interface. Slightly more involved than just copy and replace, because it has some nested objects.

Copy link
Member

@kanej kanej left a comment

Choose a reason for hiding this comment

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

I have left a comment on async usage to avoid an explicit NetworkConnection, but however that gets resolved the other changes make sense.

@alcuadrado alcuadrado added this pull request to the merge queue Oct 30, 2024
Merged via the queue into v-next with commit 62b26ef Oct 30, 2024
45 checks passed
@alcuadrado alcuadrado deleted the improve-mocha-template branch October 30, 2024 15:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants