Allow tests to be skipped

This commit is contained in:
Jacob Evans
2022-02-02 08:46:44 +10:00
parent 4d94588203
commit 5ba89a86af
2 changed files with 35 additions and 0 deletions

View File

@@ -14,4 +14,35 @@ contract TestBase is
arr = new uint256[](1);
arr[0] = v;
}
modifier requiresChainId(uint256 chainId)
{
if (chainId != _chainId())
{
emit log_string("skip: wrong chain id");
return;
}
_;
}
modifier requiresBlockNumberGte(uint256 blockNumber)
{
if (block.number < blockNumber)
{
emit log_string("skip: block.number < blockNumber");
return;
}
_;
}
function _chainId()
internal
returns (uint256 id)
{
uint256 id;
assembly {
id := chainid()
}
return id;
}
}

View File

@@ -16,13 +16,17 @@ contract UniswapV2SamplerTest is
function testUniswapV2Sell()
public
requiresChainId(1)
requiresBlockNumberGte(14000000)
{
address router = 0xf164fC0Ec4E93095b804a4795bBe1e041497b92a;
address weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address[] memory path = new address[](2);
path[0] = weth;
path[1] = usdc;
uint256[] memory values = sampler.sampleSellsFromUniswapV2Global(
router,
path