Skip to content

Feature/erc1155 tests#166

Merged
mudgen merged 5 commits into
Perfect-Abstractions:mainfrom
aapsi:feature/erc1155-tests
Nov 23, 2025
Merged

Feature/erc1155 tests#166
mudgen merged 5 commits into
Perfect-Abstractions:mainfrom
aapsi:feature/erc1155-tests

Conversation

@aapsi

@aapsi aapsi commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

ERC1155 Test Suite Implementation

Summary

Comprehensive test suite for ERC1155 with 147 passing tests covering all ERC-1155 standard requirements.

Changes

  • 75 tests for LibERC1155 internal functions
  • 72 tests for ERC1155Facet public interface
  • ✅ Test harness following ERC721 pattern (no setApprovalForAll() in lib)
  • ✅ Receiver mock with 5 error scenarios (revert, panic, custom error, etc.)
  • ✅ Data parameter forwarding tests
  • ✅ Fuzz testing for transfers and approvals

Test Coverage

Category Tests
Minting (single/batch)
Burning (single/batch)
Transfers (single/batch)
Approvals
Receiver hooks
URI management
Edge cases

Architecture

Harness Pattern

LibERC1155Harness.sol matches ERC721 pattern:

  • Wraps library internal functions: mint(), burn(), safeTransferFrom(), etc.
  • Provides test helpers with direct storage access: setApprovalForAll(), balanceOf()

Mock Implementation

ERC1155ReceiverMock.sol provides comprehensive receiver testing:

  • Configurable return values for both onERC1155Received and onERC1155BatchReceived
  • 5 error types: None, RevertWithoutMessage, RevertWithMessage, CustomError, Panic
  • Event emission with data parameter for verification
  • Immutable storage for gas efficiency
  • Tests all ERC-1155 receiver hook scenarios

Test Quality

All tests verify actual behavior:

  • Balance changes before/after operations
  • Event emission with correct parameters
  • Error messages and selector matching
  • Authorization checks
  • Receiver hook responses and data forwarding

ERC-1155 Compliance

Fully compliant - ERC1155Facet correctly implements all required public interface functions with proper data parameter forwarding.

Test Results

forge test --match-path "test/token/ERC1155/ERC1155/*.sol"
✅ 147 tests passing (0 failed, 0 skipped)
├── LibERC1155Test: 75 tests
└── ERC1155FacetTest: 72 tests

Files

test/token/ERC1155/ERC1155/LibERC1155.t.sol
test/token/ERC1155/ERC1155/ERC1155Facet.t.sol
test/token/ERC1155/ERC1155/harnesses/LibERC1155Harness.sol
test/token/ERC1155/ERC1155/mocks/ERC1155ReceiverMock.sol

Linked Issue: #148

@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

Coverage Report

Coverage

Metric Coverage Details
Lines 65% 960/1482 lines
Functions 72% 184/256 functions
Branches 53% 146/273 branches

Last updated: Mon, 03 Nov 2025 06:41:53 GMT for commit 17b4fec

@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

Gas Report

No gas usage changes detected between main and feature/erc1155-tests.

All functions maintain the same gas costs. ✅

Last updated: Mon, 03 Nov 2025 06:42:12 GMT for commit 17b4fec

@aapsi aapsi marked this pull request as ready for review November 4, 2025 04:55
@mudgen

mudgen commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

@aapsi Thanks very much for these test! @adamgall Do you want to review these tests?

@aapsi

aapsi commented Nov 22, 2025

Copy link
Copy Markdown
Contributor Author

Hi @mudgen
I will update the testcases as well, once I push the ERC1155 extension facet

@mudgen

mudgen commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

@aapsi Thanks for your work!

@mudgen mudgen merged commit 8b6f7c5 into Perfect-Abstractions:main Nov 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants