Skip to content

Add comprehensive Hardhat test suite for ListingRegistry.sol#5

Open
dominusaxis wants to merge 3 commits intoNobayprotocol:mainfrom
dominusaxis:feat/hardhat-tests
Open

Add comprehensive Hardhat test suite for ListingRegistry.sol#5
dominusaxis wants to merge 3 commits intoNobayprotocol:mainfrom
dominusaxis:feat/hardhat-tests

Conversation

@dominusaxis
Copy link

Summary

Complete Hardhat test suite for ListingRegistry.sol as requested in #3.

Tests Included (30 tests across 6 categories)

Category Tests What is Verified
Signature Validity 3 Valid EIP-712 signatures accepted, multiple sellers, correct listing IDs
Invalid Signatures 6 Wrong signer, tampered URI, tampered timestamp, tampered seller, invalid bytes, empty sig
Event Emission 4 ListingVerified on submit, ListingRevoked on revoke/forceRevoke, correct IDs across multiple
Seller Mapping & Metadata 6 Seller address, URI, timestamp, active flag, post-revocation flag, listingCount increment
Access Control 6 Seller can revoke, non-seller rejected, double-revoke rejected, owner forceRevoke, non-owner rejected, idempotent forceRevoke
Edge Cases 6 Empty URI, zero timestamp, very long URI, max uint256 timestamp, multiple listings per seller, relay submission

Technical Details

  • Uses ethers.js v6 signTypedData() for EIP-712 structured signing
  • Domain matches contract exactly: name, chainId, verifyingContract (no version field)
  • Hardhat config targets Solidity 0.8.20 with optimizer
  • OpenZeppelin v5 compatible

Setup

npm install
npx hardhat compile
npx hardhat test

Files Added

  • test/ListingRegistry.test.js — 30 comprehensive tests
  • hardhat.config.js — Hardhat configuration
  • package.json — Dependencies

Closes #3

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.

Add Hardhat test suite for ListingRegistry.sol

1 participant