Skip to content

Commit

Permalink
fix: ignore mock contracts in semver natspec script
Browse files Browse the repository at this point in the history
  • Loading branch information
agusduha committed Oct 3, 2024
1 parent c3cb7f6 commit 2b75646
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
18 changes: 7 additions & 11 deletions packages/contracts-bedrock/scripts/checks/semver-natspec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func run() error {

artifactsDir := filepath.Join(cwd, "forge-artifacts")
srcDir := filepath.Join(cwd, "src")
testDir := filepath.Join(cwd, "test")

artifactFiles, err := glob(artifactsDir, ".json")
if err != nil {
Expand All @@ -73,10 +72,6 @@ func run() error {
if err != nil {
return fmt.Errorf("failed to get contract files: %w", err)
}
testFiles, err := glob(testDir, ".sol")
if err != nil {
return fmt.Errorf("failed to get test files: %w", err)
}

var hasErr int32
var outMtx sync.Mutex
Expand Down Expand Up @@ -134,12 +129,13 @@ func run() error {
return
}

var contractPath string
if path, ok := contractFiles[contractName]; ok {
contractPath = path
} else if path, ok := testFiles[contractName]; ok {
contractPath = path
} else {
// Skip mock contracts
if strings.Contains(contractName, "_MockContract") {
return
}

contractPath := contractFiles[contractName]
if contractPath == "" {
fail("%s: Source file not found", contractName)
return
}
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +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";
import { SuperchainERC20ImplementationMock } from "test/mocks/SuperchainERC20ImplementationMock.sol";
import { SuperchainERC20Implementation_MockContract } from "test/mocks/SuperchainERC20Implementation.sol";

/// @title SuperchainERC20Test
/// @notice Contract for testing the SuperchainERC20 contract.
Expand All @@ -31,7 +31,7 @@ contract SuperchainERC20Test is Test {

/// @notice Sets up the test suite.
function setUp() public {
superchainERC20 = new SuperchainERC20ImplementationMock();
superchainERC20 = new SuperchainERC20Implementation_MockContract();
}

/// @notice Helper function to setup a mock and expect a call to it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity 0.8.25;

import { SuperchainERC20 } from "src/L2/SuperchainERC20.sol";

/// @title SuperchainERC20ImplementationMock
/// @title SuperchainERC20Implementation Mock contract
/// @notice Mock contract just to create tests over an implementation of the SuperchainERC20 abstract contract.
contract SuperchainERC20ImplementationMock is SuperchainERC20 {
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";
Expand Down

0 comments on commit 2b75646

Please sign in to comment.