Skip to content

Commit

Permalink
test: add fixture for deploying router
Browse files Browse the repository at this point in the history
this uses teh getCode / deployCode cheatcodes under the hood
to deploy both WETH9 and V3Factory which are stored as compiled
artifacts
  • Loading branch information
gakonst committed Mar 11, 2022
1 parent 604c928 commit 0d2ece5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions contracts/foundry-tests/Deploy.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pragma solidity ^0.7.6;

import "./utils/Test.sol";

import "contracts/SwapRouter.sol";

import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "@uniswap/v3-core/contracts/interfaces/IERC20Minimal.sol";

// Artifact paths for deploying from the deps folder, assumes that the command is run from
// the project root.
string constant v3FactoryArtifact = "node_modules/@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json";
string constant weth9Artifact = "test/contracts/WETH9.json";

interface WETH9 is IERC20Minimal {
function deposit() payable external;
}

// Base fixture deploying V3 Factory, V3 Router and WETH9
contract V3RouterFixture is Test {
IUniswapV3Factory public factory;
WETH9 public weth9;
SwapRouter public router;

// Deploys WETH9 and V3 Core's Factory contract, and then
// hooks them on the router
function setUp() virtual public {
address _weth9 = deployCode(weth9Artifact);
weth9 = WETH9(_weth9);

address _factory = deployCode(v3FactoryArtifact);
factory = IUniswapV3Factory(_factory);

router = new SwapRouter(_factory, _weth9);
}
}

0 comments on commit 0d2ece5

Please sign in to comment.