-
Notifications
You must be signed in to change notification settings - Fork 3
test(DEVoterVoting): add test for zero duration voting start #102
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
Conversation
Add test case to verify rejection of zero duration voting period start Remove redundant type declaration as it's now provided by hardhat-viem
WalkthroughTests in test/DEVoterVoting.ts were updated: removed manual HardhatRuntimeEnvironment viem type augmentation, added a zero-duration rejection test for startVotingPeriod, and adjusted endVotingPeriod call signature to pass an empty array as the first argument. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
test/DEVoterVoting.ts (2)
12-12
: Typings are auto‑augmented; consider a type‑only import (or drop it) to avoid runtime side effects.You can safely switch the
@nomicfoundation/hardhat-viem/types
import to a type‑only import, or remove it if tsconfig already includes the plugin types.Apply this diff:
-import "@nomicfoundation/hardhat-viem/types"; +import type "@nomicfoundation/hardhat-viem/types";
93-107
: Harden the revert assertion; prefer BigInt literal.
- Reason string matching can be brittle across clients. Use a regex to match the revert reason substring case‑insensitively.
- Prefer
0n
overBigInt(0)
for clarity.Apply this diff:
- await expect( - devoterVoting.write.startVotingPeriod([BigInt(0)], { - account: owner.account, - }) - ).to.be.rejectedWith("Invalid duration"); + await expect( + devoterVoting.write.startVotingPeriod([0n], { + account: owner.account, + }) + ).to.be.rejectedWith(/Invalid duration/i);Optional extra assertions to ensure state remained pristine:
+ expect(await devoterVoting.read.votingStartTime()).to.equal(0n); + expect(await devoterVoting.read.votingEndTime()).to.equal(0n);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
test/DEVoterVoting.ts
(3 hunks)
🔇 Additional comments (1)
test/DEVoterVoting.ts (1)
130-130
: LGTM: Explicit empty args for zero‑arg write.Passing
[]
aligns with the viem Hardhat wrappers for no‑arg functions and improves type safety. Keep this pattern consistent for other zero‑arg writes.
Add test case to verify rejection of zero duration voting period start Remove redundant type declaration as it's now provided by hardhat-viem
Summary by CodeRabbit
Tests
Chores