Skip to content

Commit

Permalink
test(contracts-rfq): remove test contracts from coverage report (#3291)
Browse files Browse the repository at this point in the history
* test: remove old test contracts from coverage

* test: remove new test contracts from coverage
  • Loading branch information
ChiTimesChi authored Oct 15, 2024
1 parent e0ce7e7 commit ea0154c
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 9 deletions.
3 changes: 3 additions & 0 deletions packages/contracts-rfq/script/FastBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts-rfq/test/FastBridgeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ 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.
// The mocked callParams are chosen to be similar to the real use cases:
// - 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts-rfq/test/FastBridgeV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts-rfq/test/MockERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ 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;

constructor(string memory name_, uint8 decimals_) ERC20(name_, name_) {
_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);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts-rfq/test/UniversalTokenLibHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol
Original file line number Diff line number Diff line change
@@ -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 {}
}
4 changes: 4 additions & 0 deletions packages/contracts-rfq/test/mocks/NonPayableRecipient.sol
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts-rfq/test/mocks/RecipientMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ea0154c

Please sign in to comment.