Skip to content

Conversation

kilnhast
Copy link
Collaborator

@kilnhast kilnhast commented Sep 15, 2025

Add test case to verify that voting period cannot be started with invalid (zero/negative) duration

Summary by CodeRabbit

  • Tests

    • No behavioral or public API changes; existing tests and coverage remain unchanged.
  • Chores

    • Minor cleanup in the test suite: removed redundant in-line commentary and leaned on standard typings to reduce maintenance.

Copy link

coderabbitai bot commented Sep 15, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Removed a single line comment in test/DEVoterVoting.ts referring to manual type declaration for @nomicfoundation/hardhat-viem; no functional or API changes.

Changes

Cohort / File(s) Summary of Changes
Comment removal
test/DEVoterVoting.ts
Deleted a line comment: "// No need for manual type declaration as it's provided by @nomicfoundation/hardhat-viem". No code or type behavior changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

A rabbit peeks at one small line,
"A comment gone — the tests still shine."
Tiny hop, a tidy sweep,
Code stays calm and sleeps to keep. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title identifies the PR's primary purpose—adding a validation test for voting duration—and is specific and readable for reviewers; however, the new test in test/DEVoterVoting.ts asserts rejection for a zero duration (BigInt(0)) rather than an explicitly negative value, so the phrase "negative duration" is slightly imprecise. Overall the title remains related to and informative about the main change.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f26c4fa and 15ca3c3.

📒 Files selected for processing (1)
  • test/DEVoterVoting.ts (0 hunks)

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.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
test/DEVoterVoting.ts (3)

12-12: LGTM: rely on hardhat-viem types; no manual HRE augmentation needed.
Nice cleanup. Optional: the explicit import of "@nomicfoundation/hardhat-viem/types" is usually redundant if the plugin is loaded in hardhat.config; consider dropping it to reduce noise.


90-90: Cast startTimeBefore to Number to avoid bigint/number mismatch.
If time.latest() returns bigint in the viem helpers, closeTo will complain. Cast explicitly:

-        expect(Number(votingStartTime)).to.be.closeTo(startTimeBefore, 5);
+        expect(Number(votingStartTime)).to.be.closeTo(Number(startTimeBefore), 5);

93-112: Rename test, use 0n, and assert generic rejection (Viem lacks hardhat-chai-matchers)

Viem-based Hardhat toolbox doesn't expose hardhat-chai-matchers (no .revertedWithCustomError). Rename the test to "non‑positive", prefer 0n, and assert .to.be.rejected.

-it("Should reject start with negative duration", async function () {
+it("Should reject start with non-positive duration", async function () {
@@
-        // Note: In Solidity, we can't directly pass negative numbers as uint256
-        // But we can test the requirement that duration must be greater than zero
-        // by using a very small duration that will be rejected
+        // Solidity uint256 can't be negative; enforce > 0 by passing 0 to hit the same check.
@@
-        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.rejected; // hardhat-viem doesn't expose .revertedWithCustomError
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b569f6 and f26c4fa.

📒 Files selected for processing (1)
  • test/DEVoterVoting.ts (3 hunks)

@metanodreamer metanodreamer reopened this Sep 16, 2025
@metanodreamer metanodreamer merged commit d0058bc into main Sep 16, 2025
1 check was pending
@nowak-token nowak-token deleted the test/negative branch September 25, 2025 18:32
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