move tests into /forked and /local
This commit is contained in:
		@@ -2,8 +2,8 @@ pragma solidity ^0.6;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pragma experimental ABIEncoderV2;
 | 
					pragma experimental ABIEncoderV2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "./utils/ForkUtils.sol";
 | 
					import "../utils/ForkUtils.sol";
 | 
				
			||||||
import "./utils/TestUtils.sol";
 | 
					import "../utils/TestUtils.sol";
 | 
				
			||||||
import "src/IZeroEx.sol";
 | 
					import "src/IZeroEx.sol";
 | 
				
			||||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
					import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
				
			||||||
import "src/features/TransformERC20Feature.sol";
 | 
					import "src/features/TransformERC20Feature.sol";
 | 
				
			||||||
@@ -15,27 +15,13 @@ import "src/features/OtcOrdersFeature.sol";
 | 
				
			|||||||
import "samplers/UniswapV2Sampler.sol";
 | 
					import "samplers/UniswapV2Sampler.sol";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
contract ETHToERC20TransformTest is Test, ForkUtils, TestUtils {
 | 
					contract ETHToERC20TransformTest is Test, ForkUtils, TestUtils {
 | 
				
			||||||
    //use forge-std json library for strings
 | 
					 | 
				
			||||||
    using stdJson for string;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    //utility mapping to get chainId by name
 | 
					 | 
				
			||||||
    mapping(string => string) public chainsByChainId;
 | 
					 | 
				
			||||||
    //utility mapping to get indexingChainId by Chain
 | 
					 | 
				
			||||||
    mapping(string => string) public indexChainsByChain;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    string json;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*//////////////////////////////////////////////////////////////
 | 
					    /*//////////////////////////////////////////////////////////////
 | 
				
			||||||
                                 Rpc Setup
 | 
					                                 Rpc Setup
 | 
				
			||||||
    //////////////////////////////////////////////////////////////*/
 | 
					    //////////////////////////////////////////////////////////////*/
 | 
				
			||||||
    function setUp() public {
 | 
					    function setUp() public {
 | 
				
			||||||
        //get out addresses.json file that defines contract addresses for each chain we are currently deployed on
 | 
					        //get out addresses.json file that defines contract addresses for each chain we are currently deployed on
 | 
				
			||||||
        createForks();
 | 
					        _setup();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (uint256 i = 0; i < chains.length; i++) {
 | 
					 | 
				
			||||||
            chainsByChainId[chains[i]] = chainIds[i];
 | 
					 | 
				
			||||||
            indexChainsByChain[chains[i]] = indexChainIds[i];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*//////////////////////////////////////////////////////////////
 | 
					    /*//////////////////////////////////////////////////////////////
 | 
				
			||||||
@@ -213,17 +199,4 @@ contract ETHToERC20TransformTest is Test, ForkUtils, TestUtils {
 | 
				
			|||||||
                                HELPERS
 | 
					                                HELPERS
 | 
				
			||||||
    //////////////////////////////////////////////////////////////*/
 | 
					    //////////////////////////////////////////////////////////////*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function createNewFQT(
 | 
					 | 
				
			||||||
        IEtherTokenV06 wrappedNativeToken,
 | 
					 | 
				
			||||||
        address payable exchangeProxy,
 | 
					 | 
				
			||||||
        address transformerDeployer
 | 
					 | 
				
			||||||
    ) public {
 | 
					 | 
				
			||||||
        vm.startPrank(transformerDeployer);
 | 
					 | 
				
			||||||
        // deploy a new instance of the bridge adapter from the transformerDeployer
 | 
					 | 
				
			||||||
        bridgeAdapter = createBridgeAdapter(IEtherTokenV06(wrappedNativeToken));
 | 
					 | 
				
			||||||
        // deploy a new instance of the fill quote transformer from the transformerDeployer
 | 
					 | 
				
			||||||
        fillQuoteTransformer = new FillQuoteTransformer(IBridgeAdapter(bridgeAdapter), IZeroEx(exchangeProxy));
 | 
					 | 
				
			||||||
        vm.label(address(fillQuoteTransformer), "zeroEx/FillQuoteTransformer");
 | 
					 | 
				
			||||||
        vm.stopPrank();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -2,8 +2,8 @@ pragma solidity ^0.6;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pragma experimental ABIEncoderV2;
 | 
					pragma experimental ABIEncoderV2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "./utils/ForkUtils.sol";
 | 
					import "../utils/ForkUtils.sol";
 | 
				
			||||||
import "./utils/TestUtils.sol";
 | 
					import "../utils/TestUtils.sol";
 | 
				
			||||||
import "src/IZeroEx.sol";
 | 
					import "src/IZeroEx.sol";
 | 
				
			||||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
					import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
				
			||||||
import "src/features/TransformERC20Feature.sol";
 | 
					import "src/features/TransformERC20Feature.sol";
 | 
				
			||||||
@@ -15,27 +15,12 @@ import "src/features/OtcOrdersFeature.sol";
 | 
				
			|||||||
import "samplers/UniswapV2Sampler.sol";
 | 
					import "samplers/UniswapV2Sampler.sol";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
contract NativeTokenToERC20WithOtcTest is Test, ForkUtils, TestUtils {
 | 
					contract NativeTokenToERC20WithOtcTest is Test, ForkUtils, TestUtils {
 | 
				
			||||||
    //use forge-std json library for strings
 | 
					 | 
				
			||||||
    using stdJson for string;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    //utility mapping to get chainId by name
 | 
					 | 
				
			||||||
    mapping(string => string) public chainsByChainId;
 | 
					 | 
				
			||||||
    //utility mapping to get indexingChainId by Chain
 | 
					 | 
				
			||||||
    mapping(string => string) public indexChainsByChain;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    string json;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*//////////////////////////////////////////////////////////////
 | 
					    /*//////////////////////////////////////////////////////////////
 | 
				
			||||||
                                 Rpc Setup
 | 
					                                 Rpc Setup
 | 
				
			||||||
    //////////////////////////////////////////////////////////////*/
 | 
					    //////////////////////////////////////////////////////////////*/
 | 
				
			||||||
    function setUp() public {
 | 
					    function setUp() public {
 | 
				
			||||||
        //get out addresses.json file that defines contract addresses for each chain we are currently deployed on
 | 
					        _setup();
 | 
				
			||||||
        createForks();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (uint256 i = 0; i < chains.length; i++) {
 | 
					 | 
				
			||||||
            chainsByChainId[chains[i]] = chainIds[i];
 | 
					 | 
				
			||||||
            indexChainsByChain[chains[i]] = indexChainIds[i];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*//////////////////////////////////////////////////////////////
 | 
					    /*//////////////////////////////////////////////////////////////
 | 
				
			||||||
@@ -136,17 +121,7 @@ contract NativeTokenToERC20WithOtcTest is Test, ForkUtils, TestUtils {
 | 
				
			|||||||
        deal(address(order.makerToken), order.maker, 1e20);
 | 
					        deal(address(order.makerToken), order.maker, 1e20);
 | 
				
			||||||
        vm.prank(order.maker);
 | 
					        vm.prank(order.maker);
 | 
				
			||||||
        IERC20TokenV06(tokens.USDC).approve(address(addresses.exchangeProxy), 1e20);
 | 
					        IERC20TokenV06(tokens.USDC).approve(address(addresses.exchangeProxy), 1e20);
 | 
				
			||||||
        // vm.startPrank(whale);
 | 
					 | 
				
			||||||
        // tokens.USDC.approve(address(this), uint(-1));
 | 
					 | 
				
			||||||
        // //tokens.USDC.transferFrom(address(whale), address(order.maker), balance);
 | 
					 | 
				
			||||||
        // balance = tokens.USDC.balanceOf(order.maker);
 | 
					 | 
				
			||||||
        // vm.stopPrank();
 | 
					 | 
				
			||||||
        //vm.deal(address(order.makerToken), address(order.maker), 1e20);
 | 
					 | 
				
			||||||
        vm.prank(order.maker);
 | 
					        vm.prank(order.maker);
 | 
				
			||||||
        // tokens.USDC.approve(
 | 
					 | 
				
			||||||
        //     address(IZERO_EX),
 | 
					 | 
				
			||||||
        //     uint256(-1)
 | 
					 | 
				
			||||||
        // );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        order.taker = address(0);
 | 
					        order.taker = address(0);
 | 
				
			||||||
        order.txOrigin = address(tx.origin);
 | 
					        order.txOrigin = address(tx.origin);
 | 
				
			||||||
@@ -195,18 +170,4 @@ contract NativeTokenToERC20WithOtcTest is Test, ForkUtils, TestUtils {
 | 
				
			|||||||
    /*//////////////////////////////////////////////////////////////
 | 
					    /*//////////////////////////////////////////////////////////////
 | 
				
			||||||
                                HELPERS
 | 
					                                HELPERS
 | 
				
			||||||
    //////////////////////////////////////////////////////////////*/
 | 
					    //////////////////////////////////////////////////////////////*/
 | 
				
			||||||
 | 
					 | 
				
			||||||
    function createNewFQT(
 | 
					 | 
				
			||||||
        IEtherTokenV06 wrappedNativeToken,
 | 
					 | 
				
			||||||
        address payable exchangeProxy,
 | 
					 | 
				
			||||||
        address transformerDeployer
 | 
					 | 
				
			||||||
    ) public {
 | 
					 | 
				
			||||||
        vm.startPrank(transformerDeployer);
 | 
					 | 
				
			||||||
        // deploy a new instance of the bridge adapter from the transformerDeployer
 | 
					 | 
				
			||||||
        bridgeAdapter = createBridgeAdapter(IEtherTokenV06(wrappedNativeToken));
 | 
					 | 
				
			||||||
        // deploy a new instance of the fill quote transformer from the transformerDeployer
 | 
					 | 
				
			||||||
        fillQuoteTransformer = new FillQuoteTransformer(IBridgeAdapter(bridgeAdapter), IZeroEx(exchangeProxy));
 | 
					 | 
				
			||||||
        vm.label(address(fillQuoteTransformer), "zeroEx/FillQuoteTransformer");
 | 
					 | 
				
			||||||
        vm.stopPrank();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -2,8 +2,8 @@ pragma solidity ^0.6;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pragma experimental ABIEncoderV2;
 | 
					pragma experimental ABIEncoderV2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "./utils/ForkUtils.sol";
 | 
					import "../utils/ForkUtils.sol";
 | 
				
			||||||
import "./utils/TestUtils.sol";
 | 
					import "../utils/TestUtils.sol";
 | 
				
			||||||
import "src/IZeroEx.sol";
 | 
					import "src/IZeroEx.sol";
 | 
				
			||||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
					import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
				
			||||||
import "src/features/TransformERC20Feature.sol";
 | 
					import "src/features/TransformERC20Feature.sol";
 | 
				
			||||||
@@ -21,29 +21,11 @@ import "src/transformers/bridges/CeloBridgeAdapter.sol";
 | 
				
			|||||||
import "src/features/OtcOrdersFeature.sol";
 | 
					import "src/features/OtcOrdersFeature.sol";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
contract transformERC20Tests is Test, ForkUtils, TestUtils {
 | 
					contract transformERC20Tests is Test, ForkUtils, TestUtils {
 | 
				
			||||||
    //use forge-std json library for strings
 | 
					    /*//////////////////////////////////////////////////////////////
 | 
				
			||||||
    using stdJson for string;
 | 
					                                 Rpc Setup
 | 
				
			||||||
 | 
					    //////////////////////////////////////////////////////////////*/
 | 
				
			||||||
    //utility mapping to get chainId by name
 | 
					 | 
				
			||||||
    mapping(string => string) public chainsByChainId;
 | 
					 | 
				
			||||||
    //utility mapping to get indexingChainId by Chain
 | 
					 | 
				
			||||||
    mapping(string => string) public indexChainsByChain;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    string json;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    function setUp() public {
 | 
					    function setUp() public {
 | 
				
			||||||
        //get out addresses.json file that defines contract addresses for each chain we are currently deployed on
 | 
					        _setup();
 | 
				
			||||||
        string memory root = vm.projectRoot();
 | 
					 | 
				
			||||||
        string memory path = string(abi.encodePacked(root, "/", "contracts/test/foundry/addresses/addresses.json"));
 | 
					 | 
				
			||||||
        json = vm.readFile(path);
 | 
					 | 
				
			||||||
        createForks();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (uint256 i = 0; i < chains.length; i++) {
 | 
					 | 
				
			||||||
            chainsByChainId[chains[i]] = chainIds[i];
 | 
					 | 
				
			||||||
            indexChainsByChain[chains[i]] = indexChainIds[i];
 | 
					 | 
				
			||||||
            bytes memory details = json.parseRaw(indexChainIds[i]);
 | 
					 | 
				
			||||||
            addresses = abi.decode(details, (Addresses));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function testTransformERC20Forked() public {
 | 
					    function testTransformERC20Forked() public {
 | 
				
			||||||
@@ -20,9 +20,9 @@
 | 
				
			|||||||
pragma solidity ^0.6;
 | 
					pragma solidity ^0.6;
 | 
				
			||||||
pragma experimental ABIEncoderV2;
 | 
					pragma experimental ABIEncoderV2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "./utils/ForkUtils.sol";
 | 
					import "../utils/ForkUtils.sol";
 | 
				
			||||||
import "./utils/TestUtils.sol";
 | 
					import "../utils/TestUtils.sol";
 | 
				
			||||||
import "./utils/DeployZeroEx.sol";
 | 
					import "../utils/DeployZeroEx.sol";
 | 
				
			||||||
import "forge-std/Test.sol";
 | 
					import "forge-std/Test.sol";
 | 
				
			||||||
import "src/IZeroEx.sol";
 | 
					import "src/IZeroEx.sol";
 | 
				
			||||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
					import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
 | 
				
			||||||
@@ -79,6 +79,9 @@ interface IFQT {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
contract ForkUtils is Test {
 | 
					contract ForkUtils is Test {
 | 
				
			||||||
    using stdJson for string;
 | 
					    using stdJson for string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    string json;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //forked providers for each chain
 | 
					    //forked providers for each chain
 | 
				
			||||||
    mapping(string => uint256) public forkIds;
 | 
					    mapping(string => uint256) public forkIds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -107,6 +110,11 @@ contract ForkUtils is Test {
 | 
				
			|||||||
    string tokensJson;
 | 
					    string tokensJson;
 | 
				
			||||||
    string sourcesJson;
 | 
					    string sourcesJson;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //utility mapping to get chainId by name
 | 
				
			||||||
 | 
					    mapping(string => string) public chainsByChainId;
 | 
				
			||||||
 | 
					    //utility mapping to get indexingChainId by Chain
 | 
				
			||||||
 | 
					    mapping(string => string) public indexChainsByChain;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function createForks() public returns (uint256[] memory) {
 | 
					    function createForks() public returns (uint256[] memory) {
 | 
				
			||||||
        for (uint256 i = 0; i < chains.length; i++) {
 | 
					        for (uint256 i = 0; i < chains.length; i++) {
 | 
				
			||||||
            forkIds[chains[i]] = vm.createFork(vm.rpcUrl(chains[i]), blockNumber[i]);
 | 
					            forkIds[chains[i]] = vm.createFork(vm.rpcUrl(chains[i]), blockNumber[i]);
 | 
				
			||||||
@@ -229,6 +237,35 @@ contract ForkUtils is Test {
 | 
				
			|||||||
        vm.label(address(sources.UniswapV2Router), "UniswapRouter");
 | 
					        vm.label(address(sources.UniswapV2Router), "UniswapRouter");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function createNewFQT(
 | 
				
			||||||
 | 
					        IEtherTokenV06 wrappedNativeToken,
 | 
				
			||||||
 | 
					        address payable exchangeProxy,
 | 
				
			||||||
 | 
					        address transformerDeployer
 | 
				
			||||||
 | 
					    ) public {
 | 
				
			||||||
 | 
					        vm.startPrank(transformerDeployer);
 | 
				
			||||||
 | 
					        // deploy a new instance of the bridge adapter from the transformerDeployer
 | 
				
			||||||
 | 
					        bridgeAdapter = createBridgeAdapter(IEtherTokenV06(wrappedNativeToken));
 | 
				
			||||||
 | 
					        // deploy a new instance of the fill quote transformer from the transformerDeployer
 | 
				
			||||||
 | 
					        fillQuoteTransformer = new FillQuoteTransformer(IBridgeAdapter(bridgeAdapter), IZeroEx(exchangeProxy));
 | 
				
			||||||
 | 
					        vm.label(address(fillQuoteTransformer), "zeroEx/FillQuoteTransformer");
 | 
				
			||||||
 | 
					        vm.stopPrank();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function _setup() public {
 | 
				
			||||||
 | 
					        //get out addresses.json file that defines contract addresses for each chain we are currently deployed on
 | 
				
			||||||
 | 
					        string memory root = vm.projectRoot();
 | 
				
			||||||
 | 
					        string memory path = string(abi.encodePacked(root, "/", "contracts/test/foundry/addresses/addresses.json"));
 | 
				
			||||||
 | 
					        json = vm.readFile(path);
 | 
				
			||||||
 | 
					        createForks();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (uint256 i = 0; i < chains.length; i++) {
 | 
				
			||||||
 | 
					            chainsByChainId[chains[i]] = chainIds[i];
 | 
				
			||||||
 | 
					            indexChainsByChain[chains[i]] = indexChainIds[i];
 | 
				
			||||||
 | 
					            bytes memory details = json.parseRaw(indexChainIds[i]);
 | 
				
			||||||
 | 
					            addresses = abi.decode(details, (Addresses));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    modifier onlyForked() {
 | 
					    modifier onlyForked() {
 | 
				
			||||||
        if (block.number >= 15000000) {
 | 
					        if (block.number >= 15000000) {
 | 
				
			||||||
            _;
 | 
					            _;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,6 +53,7 @@ contract TestUtils is Test {
 | 
				
			|||||||
        return nstr;
 | 
					        return nstr;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function _findTransformerNonce(address transformer, address deployer) internal pure returns (uint32) {
 | 
					    function _findTransformerNonce(address transformer, address deployer) internal pure returns (uint32) {
 | 
				
			||||||
        address current;
 | 
					        address current;
 | 
				
			||||||
        for (uint32 i = 0; i < 1024; i++) {
 | 
					        for (uint32 i = 0; i < 1024; i++) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user