From ae019b8c5706eb1a71a6d173c7f738cf1a6a5401 Mon Sep 17 00:00:00 2001 From: AgusDuha <81362284+agusduha@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:40:41 -0300 Subject: [PATCH] fix: semver natspec check failure (#79) * fix: semver natspec check failure * fix: ignore mock contracts in semver natspec script * fix: error message --- .../scripts/checks/semver-natspec/main.go | 7 ++++++- .../test/L2/SuperchainERC20.t.sol | 13 ++---------- .../mocks/SuperchainERC20Implementation.sol | 20 +++++++++++++++++++ 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol diff --git a/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go b/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go index d1e2153c02ef..cc65480d2c00 100644 --- a/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go +++ b/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go @@ -129,9 +129,14 @@ func run() error { return } + // Skip mock contracts + if strings.Contains(contractName, "_MockContract") { + return + } + contractPath := contractFiles[contractName] if contractPath == "" { - fail("%s: Source file not found", contractName) + fail("%s: Source file not found (For test mock contracts, suffix the name with '_MockContract' to ignore this warning)", contractName) return } diff --git a/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol b/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol index bc5785901d14..30b758a38e6d 100644 --- a/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol +++ b/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol @@ -18,16 +18,7 @@ import { BeaconProxy } from "@openzeppelin/contracts-v5/proxy/beacon/BeaconProxy // Target contract import { SuperchainERC20, ISuperchainERC20Extension } from "src/L2/SuperchainERC20.sol"; import { ISuperchainERC20Errors } from "src/L2/interfaces/ISuperchainERC20.sol"; - -contract SuperchainERC20Implementation is SuperchainERC20 { - function name() public pure override returns (string memory) { - return "SuperchainERC20"; - } - - function symbol() public pure override returns (string memory) { - return "SCE"; - } -} +import { SuperchainERC20Implementation_MockContract } from "test/mocks/SuperchainERC20Implementation.sol"; /// @title SuperchainERC20Test /// @notice Contract for testing the SuperchainERC20 contract. @@ -40,7 +31,7 @@ contract SuperchainERC20Test is Test { /// @notice Sets up the test suite. function setUp() public { - superchainERC20 = new SuperchainERC20Implementation(); + superchainERC20 = new SuperchainERC20Implementation_MockContract(); } /// @notice Helper function to setup a mock and expect a call to it. diff --git a/packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol b/packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol new file mode 100644 index 000000000000..4f3dec45896c --- /dev/null +++ b/packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.25; + +import { SuperchainERC20 } from "src/L2/SuperchainERC20.sol"; + +/// @title SuperchainERC20Implementation Mock contract +/// @notice Mock contract just to create tests over an implementation of the SuperchainERC20 abstract contract. +contract SuperchainERC20Implementation_MockContract is SuperchainERC20 { + /// @notice Semantic version. + /// @custom:semver 1.0.0-beta.1 + string public constant override version = "1.0.0-beta.1"; + + function name() public pure override returns (string memory) { + return "SuperchainERC20"; + } + + function symbol() public pure override returns (string memory) { + return "SCE"; + } +}