Skip to content

Conversation

nowak-token
Copy link
Member

@nowak-token nowak-token commented Sep 15, 2025

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

    • Added a test to verify that starting a voting period with zero duration is rejected and leaves voting inactive.
    • Updated test calls to align with the latest method signatures.
  • Chores

    • Removed custom type augmentations in tests in favor of official typings from the tooling package.

Add test case to verify rejection of zero duration voting period start
Remove redundant type declaration as it's now provided by hardhat-viem
Copy link

coderabbitai bot commented Sep 15, 2025

Walkthrough

Tests 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

Cohort / File(s) Summary
Tests: DEVoterVoting
test/DEVoterVoting.ts
Removed manual HRE viem type augmentation; added test "Should reject start with zero duration" asserting rejection with "Invalid duration" and inactive state; updated endVotingPeriod invocation to endVotingPeriod([], { account: owner.account }).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • metanodreamer

Poem

A whisk of whiskers, a tap of the key,
I nibbled the tests for solidity.
Zero-time burrow? Denied at the gate!
The vote ends clean with an empty plate.
Thump-thump—CI, let’s celebrate! 🐇✨

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 "test(DEVoterVoting): add test for zero duration voting start" is concise, follows conventional-commit style, and directly describes the primary change—adding a test that ensures starting a voting period with zero duration is rejected; it maps to the PR objectives and the modified test file. It clearly signals the scope (DEVoterVoting) and the main action (add test), making it easy for reviewers scanning history to understand the purpose. The removed type augmentation is a minor secondary change and need not be included in the title.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/start-with-zero

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: 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 over BigInt(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

📥 Commits

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

📒 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.

@metanodreamer metanodreamer merged commit 07ff670 into main Sep 15, 2025
1 check passed
@nowak-token nowak-token deleted the test/start-with-zero 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