Skip to content

Commit 18be1af

Browse files
razwwclaude
andcommitted
test: port periphery suite (routers + examples) to Hardhat
V1-free v2Fixture (no migrator / flash-swap); full suite is 145 passing. - port ListaV2Router01/02 and 4 example specs to ethers v5 + hardhat-waffle - Router01: single module-level fixture-loader with hooks scoped inside the per-version describe (the shared Hardhat chain corrupts EVM snapshots when the loop registers hooks + a second loader at the outer describe scope) - oracle specs: add allowBlocksWithSameTimestamp + initialDate (2019) and an anchor-mining mineBlock to reproduce the ganache clock model they assume - swapExactETHForTokens gas snapshot 138770 -> 138700 (fork bytecode) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7123403 commit 18be1af

10 files changed

Lines changed: 2264 additions & 0 deletions

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ contracts/
3737
periphery/ # forked from Uniswap/v2-periphery (solc 0.6.6)
3838
test/
3939
core/ # ported Uniswap V2 core specs (Hardhat + ethers v5 + waffle matchers)
40+
periphery/ # ported router + example specs (V1-free fixture, no migrator/flash-swap)
4041
```
4142

43+
The full suite (core + periphery) is **145 tests**. The Uniswap V1 migrator and
44+
V1↔V2 flash-swap specs are intentionally absent, matching the removed contracts.
45+
A few gas-snapshot constants were adjusted to this fork's bytecode, and the
46+
timestamp-sensitive oracle specs rely on `allowBlocksWithSameTimestamp` +
47+
`initialDate` (set in `hardhat.config.ts`) to reproduce the ganache clock model
48+
they were written against.
49+
4250
Periphery imports that originally referenced the `@uniswap/v2-core` npm package
4351
have been rewired to the local `contracts/core` fork. `@uniswap/lib` imports are
4452
resolved from `node_modules` as before.

hardhat.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ const config: HardhatUserConfig = {
2626
chainId: 1,
2727
hardfork: "istanbul",
2828
allowUnlimitedContractSize: true,
29+
// Start the chain before 2020 so the sliding-window oracle spec can set
30+
// its absolute start timestamp (1577836800 = 2020-01-01) going forward.
31+
initialDate: "2019-01-01T00:00:00Z",
32+
// The Uniswap oracle specs were written against ganache, where consecutive
33+
// txs in the same real second share a block timestamp. Allow that here so
34+
// setup txs don't drift past the anchored start time.
35+
allowBlocksWithSameTimestamp: true,
2936
},
3037
},
3138
paths: {

0 commit comments

Comments
 (0)