Skip to content

test: add unit tests for ERC-20 invoice coverage - #201

Open
eshaanag wants to merge 1 commit into
StabilityNexus:mainfrom
eshaanag:test-erc20-invoice-coverage
Open

test: add unit tests for ERC-20 invoice coverage#201
eshaanag wants to merge 1 commit into
StabilityNexus:mainfrom
eshaanag:test-erc20-invoice-coverage

Conversation

@eshaanag

Copy link
Copy Markdown

Description

This PR introduces comprehensive unit tests for the ERC-20 invoice creation, payment, and batch payment code paths in the Chainvoice contract.

Previously, only native ether invoice workflows were tested in the suite. This change ensures that the contract's token interactions (balance verification, allowance checking, and transfers) are fully covered and verified.

Changes Made

  • Introduced a MockERC20 token helper inside the test file contracts/test/Chainvoice.t.sol.
  • Added testCreateInvoice_ERC20(): Verifies successful ERC-20 invoice creation.
  • Added testPayInvoice_ERC20(): Verifies successful invoice payment via approved ERC-20 tokens.
  • Added testPayInvoice_ERC20_RevertInsufficientAllowance(): Asserts that payments revert when the payer has not approved the contract.
  • Added testPayInvoice_ERC20_RevertFeeMustBeNative(): Asserts that payments revert if the native fee is not sent.
  • Added testPayInvoicesBatch_ERC20(): Verifies batch payment processing for multiple ERC-20 invoices.

Verification

All 33 contract tests pass successfully under Foundry:

forge test

Introduce MockERC20 token contract to tests and write unit tests covering ERC-20 invoice creation, payment, and batch payment paths.
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ec0af2e3-27d0-4f4e-8e17-8f40c70d59aa


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.

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.

1 participant