Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Foundry tests for EAS.sol #13538

Open
wants to merge 98 commits into
base: develop
Choose a base branch
from

Conversation

Red-Pandaz
Copy link

Description

This PR adds EAS.t.sol, a comprehensive test suite for the EAS (Ethereum Attestation Service) contract implementation. The test suite verifies core EAS functionality including:

  • Contract construction and initialization
  • EIP-712 signature verification for attestations
  • Direct and delegated attestation flows
  • Multi-attestation handling
  • Revocation functionality
  • Error cases and edge conditions

Tests

The test suite includes:

  • Construction Tests

    • Initial contract state verification
    • Invalid schema registry handling
  • Signature Verification Tests

    • Expired deadline handling
    • Invalid signer detection
    • Data tampering prevention
    • Direct and delegated signature flows
    • Proxy attestation verification
  • Attestation Tests

    • Basic schema-based attestations
    • Resolver integration
    • Expiration time validation
    • Schema-less attestations
    • Delegated attestations
      • Single and multi-delegated flows
      • Signature verification
      • Deadline handling
    • Multi-attestation scenarios
      • Batch processing
      • Multiple recipients
      • Error handling
  • Revocation Tests

    • Direct revocation
    • Delegated revocation
    • Multi-revocation scenarios
    • Irrevocable schema handling
    • Off-chain revocation
    • Invalid revocation attempts
  • Timestamping Tests

    • Single and batch timestamping
    • Timestamp duplication prevention
    • Verification scenarios
    • Unregistered timestamp handling

All tests use the Forge testing framework and include fuzz testing for enhanced coverage.

Changes to Supporting Files

  • Updated Setup.sol to include IEAS and ISchemaRegistry interfaces for proper test initialization and integration (SchemaRegistry.sol tests have been written and can be added in a future PR)

@Red-Pandaz Red-Pandaz requested a review from a team as a code owner December 27, 2024 17:54
@Red-Pandaz Red-Pandaz requested a review from ajsutton December 27, 2024 17:54
@tynes
Copy link
Contributor

tynes commented Jan 1, 2025

/ci authorize 3b8e02b

@tynes tynes requested review from AmadiMichael and removed request for ajsutton January 1, 2025 00:38
@tynes
Copy link
Contributor

tynes commented Jan 1, 2025

go run ./scripts/checks/unused-imports
❌  test/vendor/eas/EAS.t.sol: IERC1271
❌  test/vendor/eas/EAS.t.sol: Strings
❌  test/vendor/eas/EAS.t.sol: ECDSA
error: processing failed
exit status 1
error: Recipe `unused-imports-check-no-build` failed on line 233 with exit code 1

Try fixing this and pushing another commit

@tynes
Copy link
Contributor

tynes commented Jan 1, 2025

/ci authorize 7c8354b

@tynes
Copy link
Contributor

tynes commented Jan 1, 2025

Run just lint and commit the diff. Then run just gas-snapshot and commit the diff

@tynes
Copy link
Contributor

tynes commented Jan 1, 2025

/ci authorize b3e3c4a

@tynes
Copy link
Contributor

tynes commented Jan 2, 2025

/ci authorize 6d88f14

@tynes
Copy link
Contributor

tynes commented Jan 3, 2025

/ci authorize 9440c30

@@ -0,0 +1,3080 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.15;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: nowhere else in the codebase does it do =0.8.15, this is semantically correct but also equivalent to just 0.8.15 which the rest of the codebase uses

}
}

// Mainnet Contract
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this comment isn't useful

error DeadlineExpired();

// Test State
ISchemaRegistry public registry;
Copy link
Contributor

Choose a reason for hiding this comment

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

registry looks unused. Can you make sure there aren't any unused variables here?

@tynes
Copy link
Contributor

tynes commented Jan 6, 2025

/ci authorize 444c106

@tynes
Copy link
Contributor

tynes commented Jan 14, 2025

Looks like this needs a rebase, its a small conflict

@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is only used in the test file, I think its fine to define in there, unless the linter requires this file to exist

Copy link
Author

Choose a reason for hiding this comment

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

The interface was moved into its own file to fix a CI testing failure. I can't recall the specific error but it was related to the Solidity version.

Red-Pandaz and others added 29 commits January 13, 2025 23:17
…tion_invalidLength_reverts and test_attestation_dataScenarios_succeeds
…ime_succeeds and test_attestation_delegated_succeeds
…_succeeds and test_cascadingRevocation_succeeds
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.

3 participants