From 52a11de9768a06c125d59e4bc3460b5d9bd2df3e Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:14:20 +0100 Subject: [PATCH 1/2] test: remove old test contracts from coverage --- packages/contracts-rfq/script/FastBridge.s.sol | 3 +++ packages/contracts-rfq/test/FastBridgeMock.sol | 3 +++ packages/contracts-rfq/test/MockERC20.sol | 4 ++++ packages/contracts-rfq/test/UniversalTokenLibHarness.sol | 5 ++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/contracts-rfq/script/FastBridge.s.sol b/packages/contracts-rfq/script/FastBridge.s.sol index 84d048575d..de3208889f 100644 --- a/packages/contracts-rfq/script/FastBridge.s.sol +++ b/packages/contracts-rfq/script/FastBridge.s.sol @@ -7,6 +7,9 @@ import {Script} from "forge-std/Script.sol"; contract DeployFastBridge is Script { FastBridge public bridge; + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testDeployFastBridge() external {} + /// e.g. forge script contracts/script/FastBridge.s.sol --sig "run(address, address[])" 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 "[0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f]" function run(address owner, address[] memory relayers) external { vm.startBroadcast(); diff --git a/packages/contracts-rfq/test/FastBridgeMock.sol b/packages/contracts-rfq/test/FastBridgeMock.sol index 0f035c3430..a84ce7db72 100644 --- a/packages/contracts-rfq/test/FastBridgeMock.sol +++ b/packages/contracts-rfq/test/FastBridgeMock.sol @@ -16,6 +16,9 @@ contract FastBridgeMock is IFastBridge, Admin { /// @dev to prevent replays uint256 public nonce; + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeMock() external {} + function getBridgeTransaction(bytes memory request) public pure returns (BridgeTransaction memory) { return abi.decode(request, (BridgeTransaction)); } diff --git a/packages/contracts-rfq/test/MockERC20.sol b/packages/contracts-rfq/test/MockERC20.sol index f4c07d49aa..b0e2f67d99 100644 --- a/packages/contracts-rfq/test/MockERC20.sol +++ b/packages/contracts-rfq/test/MockERC20.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.17; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +// solhint-disable no-empty-blocks contract MockERC20 is ERC20 { uint8 private _decimals; @@ -10,6 +11,9 @@ contract MockERC20 is ERC20 { _decimals = decimals_; } + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testMockERC20() external {} + function burn(address account, uint256 amount) external { _burn(account, amount); } diff --git a/packages/contracts-rfq/test/UniversalTokenLibHarness.sol b/packages/contracts-rfq/test/UniversalTokenLibHarness.sol index 7f8d2d6753..5e628b5fa2 100644 --- a/packages/contracts-rfq/test/UniversalTokenLibHarness.sol +++ b/packages/contracts-rfq/test/UniversalTokenLibHarness.sol @@ -3,8 +3,11 @@ pragma solidity ^0.8.17; import {UniversalTokenLib} from "../contracts/libs/UniversalToken.sol"; -// solhint-disable ordering +// solhint-disable no-empty-blocks, ordering contract UniversalTokenLibHarness { + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testUniversalTokenLibHarness() external {} + function universalTransfer(address token, address to, uint256 value) public { UniversalTokenLib.universalTransfer(token, to, value); } From 0799a1d516069d2c88d3ccf624d028b4fdff57e1 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:19:21 +0100 Subject: [PATCH 2/2] test: remove new test contracts from coverage --- packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol | 5 ++++- .../test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol | 5 ++++- .../contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol | 5 ++++- .../test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol | 5 ++++- .../test/FastBridgeV2.GasBench.Src.PFees.t.sol | 5 ++++- .../contracts-rfq/test/FastBridgeV2.Src.ProtocolFees.t.sol | 5 ++++- packages/contracts-rfq/test/FastBridgeV2.t.sol | 3 +++ .../contracts-rfq/test/harnesses/MulticallTargetHarness.sol | 4 ++++ .../test/mocks/ExcessiveReturnValueRecipient.sol | 4 ++++ .../test/mocks/IncorrectReturnValueRecipient.sol | 4 ++++ .../contracts-rfq/test/mocks/NoReturnValueRecipient.sol | 6 ++++-- packages/contracts-rfq/test/mocks/NonPayableRecipient.sol | 4 ++++ packages/contracts-rfq/test/mocks/RecipientMock.sol | 4 ++++ 13 files changed, 51 insertions(+), 8 deletions(-) diff --git a/packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol b/packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol index 9e79e48489..f499136cfe 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol @@ -3,10 +3,13 @@ pragma solidity ^0.8.20; import {FastBridgeV2, FastBridgeV2Test, IFastBridgeV2} from "./FastBridgeV2.t.sol"; -// solhint-disable func-name-mixedcase, ordering +// solhint-disable func-name-mixedcase, no-empty-blocks contract FastBridgeV2DstBaseTest is FastBridgeV2Test { uint256 public constant LEFTOVER_BALANCE = 1 ether; + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeV2DstBaseTest() external {} + function setUp() public virtual override { vm.chainId(DST_CHAIN_ID); super.setUp(); diff --git a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol index 1fe2da38ab..55958e937f 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; import {FastBridgeV2GasBenchmarkDstTest} from "./FastBridgeV2.GasBench.Dst.t.sol"; import {RecipientMock} from "./mocks/RecipientMock.sol"; -// solhint-disable func-name-mixedcase, ordering +// solhint-disable func-name-mixedcase, no-empty-blocks contract FastBridgeV2GasBenchmarkDstArbitraryCallTest is FastBridgeV2GasBenchmarkDstTest { // To get an idea about how much overhead the arbitrary call adds to the relaying process, we use a mock // recipient that has the hook function implemented as a no-op. @@ -12,6 +12,9 @@ contract FastBridgeV2GasBenchmarkDstArbitraryCallTest is FastBridgeV2GasBenchmar // - user address // - some kind of ID to decide what to do with the tokens next + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeV2GasBenchmarkDstArbitraryCallTest() external {} + function setUp() public virtual override { // In the inherited tests userB is always used as the recipient of the tokens. userB = address(new RecipientMock()); diff --git a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol index 685dab76a4..970f51465b 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol @@ -3,10 +3,13 @@ pragma solidity ^0.8.20; import {FastBridgeV2GasBenchmarkDstTest} from "./FastBridgeV2.GasBench.Dst.t.sol"; -// solhint-disable func-name-mixedcase, ordering +// solhint-disable func-name-mixedcase, no-empty-blocks contract FastBridgeV2GasBenchmarkDstExclusivityTest is FastBridgeV2GasBenchmarkDstTest { uint256 public constant EXCLUSIVITY_PERIOD = 60 seconds; + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeV2GasBenchmarkDstExclusivityTest() external {} + function setUp() public virtual override { super.setUp(); skip({time: EXCLUSIVITY_PERIOD / 2}); diff --git a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol index e806f27544..d9291b8208 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol @@ -3,8 +3,11 @@ pragma solidity ^0.8.20; import {FastBridgeV2GasBenchmarkSrcTest} from "./FastBridgeV2.GasBench.Src.t.sol"; -// solhint-disable func-name-mixedcase, ordering +// solhint-disable func-name-mixedcase, no-empty-blocks contract FastBridgeV2GasBenchmarkSrcArbitraryCallTest is FastBridgeV2GasBenchmarkSrcTest { + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeV2GasBenchmarkSrcArbitraryCallTest() external {} + function createFixturesV2() public virtual override { super.createFixturesV2(); bytes memory mockCallParams = abi.encode(userA, keccak256("Random ID")); diff --git a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol index 51f17b5a96..790db012f6 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol @@ -3,8 +3,11 @@ pragma solidity ^0.8.20; import {FastBridgeV2GasBenchmarkSrcTest} from "./FastBridgeV2.GasBench.Src.t.sol"; -// solhint-disable func-name-mixedcase, ordering +// solhint-disable func-name-mixedcase, no-empty-blocks contract FastBridgeV2GasBenchmarkSrcProtocolFeesTest is FastBridgeV2GasBenchmarkSrcTest { + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeV2GasBenchmarkSrcProtocolFeesTest() external {} + function configureFastBridge() public virtual override { super.configureFastBridge(); fastBridge.grantRole(fastBridge.GOVERNOR_ROLE(), address(this)); diff --git a/packages/contracts-rfq/test/FastBridgeV2.Src.ProtocolFees.t.sol b/packages/contracts-rfq/test/FastBridgeV2.Src.ProtocolFees.t.sol index d9a5324ed1..775ff257e5 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.Src.ProtocolFees.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.Src.ProtocolFees.t.sol @@ -3,8 +3,11 @@ pragma solidity ^0.8.20; import {FastBridgeV2SrcTest} from "./FastBridgeV2.Src.t.sol"; -// solhint-disable func-name-mixedcase, ordering +// solhint-disable func-name-mixedcase, no-empty-blocks contract FastBridgeV2SrcProtocolFeesTest is FastBridgeV2SrcTest { + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeV2SrcProtocolFeesTest() external {} + function configureFastBridge() public virtual override { super.configureFastBridge(); fastBridge.grantRole(fastBridge.GOVERNOR_ROLE(), address(this)); diff --git a/packages/contracts-rfq/test/FastBridgeV2.t.sol b/packages/contracts-rfq/test/FastBridgeV2.t.sol index fca2bad7c3..1a0c3645a3 100644 --- a/packages/contracts-rfq/test/FastBridgeV2.t.sol +++ b/packages/contracts-rfq/test/FastBridgeV2.t.sol @@ -44,6 +44,9 @@ abstract contract FastBridgeV2Test is Test, IFastBridgeV2Errors { IFastBridgeV2.BridgeParamsV2 internal tokenParamsV2; IFastBridgeV2.BridgeParamsV2 internal ethParamsV2; + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testFastBridgeV2Test() external {} + function setUp() public virtual { srcToken = new MockERC20("SrcToken", 6); dstToken = new MockERC20("DstToken", 6); diff --git a/packages/contracts-rfq/test/harnesses/MulticallTargetHarness.sol b/packages/contracts-rfq/test/harnesses/MulticallTargetHarness.sol index 5819dbf3fc..4a2e527f22 100644 --- a/packages/contracts-rfq/test/harnesses/MulticallTargetHarness.sol +++ b/packages/contracts-rfq/test/harnesses/MulticallTargetHarness.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.0; import {MulticallTarget} from "../../contracts/utils/MulticallTarget.sol"; +// solhint-disable no-empty-blocks contract MulticallTargetHarness is MulticallTarget { address public addressField; uint256 public uintField; @@ -11,6 +12,9 @@ contract MulticallTargetHarness is MulticallTarget { error CustomError(); + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testMulticallTargetHarness() external {} + function setMsgSenderAsAddressField() external returns (address) { addressField = msg.sender; return addressField; diff --git a/packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol b/packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol index 9c3be02502..21f3484dd7 100644 --- a/packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol +++ b/packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol @@ -3,11 +3,15 @@ pragma solidity ^0.8.0; import {IFastBridgeRecipient} from "../../contracts/interfaces/IFastBridgeRecipient.sol"; +// solhint-disable no-empty-blocks /// @notice Incorrectly implemented recipient mock for testing purposes. DO NOT USE IN PRODUCTION. contract ExcessiveReturnValueRecipient { /// @notice Mock needs to accept ETH receive() external payable {} + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testExcessiveReturnValueRecipient() external {} + /// @notice Incorrectly implemented - method returns excessive bytes. function fastBridgeTransferReceived(address, uint256, bytes memory) external payable returns (bytes4, uint256) { return (IFastBridgeRecipient.fastBridgeTransferReceived.selector, 1337); diff --git a/packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol b/packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol index 2bf955da7f..0570f49cd0 100644 --- a/packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol +++ b/packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol @@ -3,11 +3,15 @@ pragma solidity ^0.8.0; import {IFastBridgeRecipient} from "../../contracts/interfaces/IFastBridgeRecipient.sol"; +// solhint-disable no-empty-blocks /// @notice Incorrectly implemented recipient mock for testing purposes. DO NOT USE IN PRODUCTION. contract IncorrectReturnValueRecipient is IFastBridgeRecipient { /// @notice Mock needs to accept ETH receive() external payable {} + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testIncorrectReturnValueRecipient() external {} + /// @notice Incorrectly implemented - method returns incorrect value. function fastBridgeTransferReceived(address, uint256, bytes memory) external payable returns (bytes4) { // Flip the last bit diff --git a/packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol b/packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol index e10c8b6ded..1ba76e7402 100644 --- a/packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol +++ b/packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol @@ -1,13 +1,15 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -// solhint-disable - +// solhint-disable no-empty-blocks /// @notice Incorrectly implemented recipient mock for testing purposes. DO NOT USE IN PRODUCTION. contract NoReturnValueRecipient { /// @notice Mock needs to accept ETH receive() external payable {} + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testNoReturnValueRecipient() external {} + /// @notice Incorrectly implemented - method does not return anything. function fastBridgeTransferReceived(address, uint256, bytes memory) external payable {} } diff --git a/packages/contracts-rfq/test/mocks/NonPayableRecipient.sol b/packages/contracts-rfq/test/mocks/NonPayableRecipient.sol index 1f53dabfd1..2c80581943 100644 --- a/packages/contracts-rfq/test/mocks/NonPayableRecipient.sol +++ b/packages/contracts-rfq/test/mocks/NonPayableRecipient.sol @@ -1,8 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; +// solhint-disable no-empty-blocks /// @notice Incorrectly implemented recipient mock for testing purposes. DO NOT USE IN PRODUCTION. contract NonPayableRecipient { + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testNonPayableRecipient() external {} + /// @notice Incorrectly implemented - method is not payable. function fastBridgeTransferReceived(address, uint256, bytes memory) external pure returns (bytes4) { return NonPayableRecipient.fastBridgeTransferReceived.selector; diff --git a/packages/contracts-rfq/test/mocks/RecipientMock.sol b/packages/contracts-rfq/test/mocks/RecipientMock.sol index a35d4ac5ec..f95422b322 100644 --- a/packages/contracts-rfq/test/mocks/RecipientMock.sol +++ b/packages/contracts-rfq/test/mocks/RecipientMock.sol @@ -3,11 +3,15 @@ pragma solidity ^0.8.0; import {IFastBridgeRecipient} from "../../contracts/interfaces/IFastBridgeRecipient.sol"; +// solhint-disable no-empty-blocks /// @notice Recipient mock for testing purposes. DO NOT USE IN PRODUCTION. contract RecipientMock is IFastBridgeRecipient { /// @notice Mock needs to accept ETH receive() external payable {} + /// @notice We include an empty "test" function so that this contract does not appear in the coverage report. + function testRecipientMock() external {} + /// @notice Minimal viable implementation of the fastBridgeTransferReceived hook. function fastBridgeTransferReceived(address, uint256, bytes memory) external payable returns (bytes4) { return IFastBridgeRecipient.fastBridgeTransferReceived.selector;