Skip to content

Commit

Permalink
fix: test contracts to test folder (#162)
Browse files Browse the repository at this point in the history
## Description

Moves files from `src/contracts/test` to `test/src` (from which they
will be further pulled out until no contract is left there.
This is to avoid triggering the mandatory two reviews check on PRs that
move these files to the test folder.

This PR will be merged with a single review.

## Test Plan

Code compiles. Number of changes is constant before `fmt`.
  • Loading branch information
fedgiac authored Jun 7, 2024
1 parent 36bb25b commit a10f407
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .solhintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/contracts/test/vendor/
src/contracts/test
1 change: 1 addition & 0 deletions src/contracts/test
13 changes: 0 additions & 13 deletions src/contracts/test/GPv2AllowListAuthenticationTestInterface.sol

This file was deleted.

33 changes: 0 additions & 33 deletions src/contracts/test/GPv2TransferTestInterface.sol

This file was deleted.

2 changes: 1 addition & 1 deletion test/reader/StorageAccessible.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import {Test, Vm} from "forge-std/Test.sol";
import {StorageAccessibleWrapper, ExternalStorageReader} from "src/contracts/test/vendor/StorageAccessibleWrapper.sol";
import {StorageAccessibleWrapper, ExternalStorageReader} from "test/src/vendor/StorageAccessibleWrapper.sol";
import {ViewStorageAccessible} from "src/contracts/mixins/StorageAccessible.sol";

contract StorageAccessibleTest is Test {
Expand Down
2 changes: 1 addition & 1 deletion test/reader/StorageReadable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import {Test} from "forge-std/Test.sol";
import {StorageAccessibleWrapper} from "src/contracts/test/vendor/StorageAccessibleWrapper.sol";
import {StorageAccessibleWrapper} from "test/src/vendor/StorageAccessibleWrapper.sol";

contract StorageReadableTest is Test {
StorageAccessibleWrapper instance;
Expand Down
2 changes: 1 addition & 1 deletion test/reader/ViewStorageAccessible.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import {Test} from "forge-std/Test.sol";
import {StorageAccessibleWrapper, ExternalStorageReader} from "src/contracts/test/vendor/StorageAccessibleWrapper.sol";
import {StorageAccessibleWrapper, ExternalStorageReader} from "test/src/vendor/StorageAccessibleWrapper.sol";
import {ViewStorageAccessible} from "src/contracts/mixins/StorageAccessible.sol";

contract StorageAccessibleTest is Test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ import "@openzeppelin/contracts/drafts/ERC20Permit.sol";
import "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol";

contract ERC20PresetPermit is ERC20Permit {
constructor(
string memory symbol
)
ERC20(symbol, symbol)
ERC20Permit(symbol)
constructor(string memory symbol) ERC20(symbol, symbol) ERC20Permit(symbol)
// solhint-disable-next-line no-empty-blocks
{

}
{}

function mint(address to, uint256 amount) external {
_mint(to, amount);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ contract FeeClaimingERC20 is ERC20PresetMinterPauser {
// solhint-disable-next-line no-empty-blocks
constructor() ERC20PresetMinterPauser("FEE", "FEE") {}

function _transfer(
address sender,
address recipient,
uint256 amount
) internal override {
function _transfer(address sender, address recipient, uint256 amount) internal override {
uint256 finalAmount = (amount * 99) / 100;
uint256 burnAmount = amount - finalAmount;

Expand Down
11 changes: 11 additions & 0 deletions test/src/GPv2AllowListAuthenticationTestInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity >=0.7.6 <0.9.0;

import "src/contracts/GPv2AllowListAuthentication.sol";
import "src/contracts/libraries/GPv2EIP1967.sol";

contract GPv2AllowListAuthenticationTestInterface is GPv2AllowListAuthentication {
constructor(address owner) {
GPv2EIP1967.setAdmin(owner);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity >=0.7.6 <0.9.0;

import "../GPv2AllowListAuthentication.sol";
import "src/contracts/GPv2AllowListAuthentication.sol";

contract GPv2AllowListAuthenticationV2 is GPv2AllowListAuthentication {
function newMethod() external pure returns (uint256) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Interaction.sol";
import "src/contracts/libraries/GPv2Interaction.sol";

contract GPv2InteractionTestInterface {
// solhint-disable-next-line no-empty-blocks
Expand All @@ -12,9 +12,7 @@ contract GPv2InteractionTestInterface {
GPv2Interaction.execute(interaction);
}

function selectorTest(
GPv2Interaction.Data calldata interaction
) external pure returns (bytes4) {
function selectorTest(GPv2Interaction.Data calldata interaction) external pure returns (bytes4) {
return GPv2Interaction.selector(interaction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Order.sol";
import "src/contracts/libraries/GPv2Order.sol";

contract GPv2OrderTestInterface {
using GPv2Order for GPv2Order.Data;
Expand All @@ -12,26 +12,24 @@ contract GPv2OrderTestInterface {
return GPv2Order.TYPE_HASH;
}

function hashTest(
GPv2Order.Data memory order,
bytes32 domainSeparator
) external pure returns (bytes32 orderDigest) {
function hashTest(GPv2Order.Data memory order, bytes32 domainSeparator)
external
pure
returns (bytes32 orderDigest)
{
orderDigest = order.hash(domainSeparator);
}

function packOrderUidParamsTest(
uint256 bufferLength,
bytes32 orderDigest,
address owner,
uint32 validTo
) external pure returns (bytes memory orderUid) {
function packOrderUidParamsTest(uint256 bufferLength, bytes32 orderDigest, address owner, uint32 validTo)
external
pure
returns (bytes memory orderUid)
{
orderUid = new bytes(bufferLength);
orderUid.packOrderUidParams(orderDigest, owner, validTo);
}

function extractOrderUidParamsTest(
bytes calldata orderUid
)
function extractOrderUidParamsTest(bytes calldata orderUid)
external
pure
returns (bytes32 orderDigest, address owner, uint32 validTo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../GPv2Settlement.sol";
import "../libraries/GPv2Interaction.sol";
import "../libraries/GPv2Trade.sol";
import "../libraries/GPv2Transfer.sol";
import "src/contracts/GPv2Settlement.sol";
import "src/contracts/libraries/GPv2Interaction.sol";
import "src/contracts/libraries/GPv2Trade.sol";
import "src/contracts/libraries/GPv2Transfer.sol";

contract GPv2SettlementTestInterface is GPv2Settlement {
constructor(
GPv2Authentication authenticator_,
IVault vault
)
GPv2Settlement(authenticator_, vault)
constructor(GPv2Authentication authenticator_, IVault vault) GPv2Settlement(authenticator_, vault)
// solhint-disable-next-line no-empty-blocks
{

}
{}

function setFilledAmount(bytes calldata orderUid, uint256 amount) external {
filledAmount[orderUid] = amount;
Expand All @@ -26,18 +20,8 @@ contract GPv2SettlementTestInterface is GPv2Settlement {
IERC20[] calldata tokens,
uint256[] calldata clearingPrices,
GPv2Trade.Data[] calldata trades
)
external
returns (
GPv2Transfer.Data[] memory inTransfers,
GPv2Transfer.Data[] memory outTransfers
)
{
(inTransfers, outTransfers) = computeTradeExecutions(
tokens,
clearingPrices,
trades
);
) external returns (GPv2Transfer.Data[] memory inTransfers, GPv2Transfer.Data[] memory outTransfers) {
(inTransfers, outTransfers) = computeTradeExecutions(tokens, clearingPrices, trades);
}

function computeTradeExecutionMemoryTest() external returns (uint256 mem) {
Expand All @@ -63,9 +47,7 @@ contract GPv2SettlementTestInterface is GPv2Settlement {
}
}

function executeInteractionsTest(
GPv2Interaction.Data[] calldata interactions
) external {
function executeInteractionsTest(GPv2Interaction.Data[] calldata interactions) external {
executeInteractions(interactions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Order.sol";
import "../libraries/GPv2Trade.sol";
import "../mixins/GPv2Signing.sol";
import "src/contracts/libraries/GPv2Order.sol";
import "src/contracts/libraries/GPv2Trade.sol";
import "src/contracts/mixins/GPv2Signing.sol";

contract GPv2SigningTestInterface is GPv2Signing {
function recoverOrderFromTradeTest(
IERC20[] calldata tokens,
GPv2Trade.Data calldata trade
) external view returns (RecoveredOrder memory recoveredOrder) {
function recoverOrderFromTradeTest(IERC20[] calldata tokens, GPv2Trade.Data calldata trade)
external
view
returns (RecoveredOrder memory recoveredOrder)
{
recoveredOrder = allocateRecoveredOrder();
recoverOrderFromTrade(recoveredOrder, tokens, trade);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "../libraries/GPv2Order.sol";
import "../libraries/GPv2Trade.sol";
import "src/contracts/libraries/GPv2Order.sol";
import "src/contracts/libraries/GPv2Trade.sol";

contract GPv2TradeTestInterface {
function extractOrderTest(
IERC20[] calldata tokens,
GPv2Trade.Data calldata trade
) external pure returns (GPv2Order.Data memory order) {
function extractOrderTest(IERC20[] calldata tokens, GPv2Trade.Data calldata trade)
external
pure
returns (GPv2Order.Data memory order)
{
GPv2Trade.extractOrder(trade, tokens, order);
}

function extractFlagsTest(
uint256 flags
)
function extractFlagsTest(uint256 flags)
external
pure
returns (
Expand Down
26 changes: 26 additions & 0 deletions test/src/GPv2TransferTestInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity >=0.7.6 <0.9.0;
pragma abicoder v2;

import "src/contracts/libraries/GPv2Transfer.sol";

contract GPv2TransferTestInterface {
function fastTransferFromAccountTest(IVault vault, GPv2Transfer.Data calldata transfer, address recipient)
external
{
GPv2Transfer.fastTransferFromAccount(vault, transfer, recipient);
}

function transferFromAccountsTest(IVault vault, GPv2Transfer.Data[] calldata transfers, address recipient)
external
{
GPv2Transfer.transferFromAccounts(vault, transfers, recipient);
}

function transferToAccountsTest(IVault vault, GPv2Transfer.Data[] memory transfers) external {
GPv2Transfer.transferToAccounts(vault, transfers);
}

// solhint-disable-next-line no-empty-blocks
receive() external payable {}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity >=0.7.6 <0.9.0;

import "../libraries/SafeMath.sol";
import "src/contracts/libraries/SafeMath.sol";

abstract contract NonStandardERC20 {
using SafeMath for uint256;
Expand Down Expand Up @@ -41,19 +41,14 @@ contract ERC20NoReturn is NonStandardERC20 {

contract ERC20ReturningUint is NonStandardERC20 {
// Largest 256-bit prime :)
uint256 private constant OK =
115792089237316195423570985008687907853269984665640564039457584007913129639747;
uint256 private constant OK = 115792089237316195423570985008687907853269984665640564039457584007913129639747;

function transfer(address to, uint256 amount) external returns (uint256) {
transfer_(to, amount);
return OK;
}

function transferFrom(
address from,
address to,
uint256 amount
) external returns (uint256) {
function transferFrom(address from, address to, uint256 amount) external returns (uint256) {
transferFrom_(from, to, amount);
return OK;
}
Expand Down
Loading

0 comments on commit a10f407

Please sign in to comment.