forked from superrare/v3-periphery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoolAddress.spec.ts
72 lines (61 loc) · 2.27 KB
/
PoolAddress.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { constants } from 'ethers'
import { waffle, ethers } from 'hardhat'
import { PoolAddressTest } from '../typechain'
import { POOL_BYTECODE_HASH } from './shared/computePoolAddress'
import { expect } from './shared/expect'
import snapshotGasCost from './shared/snapshotGasCost'
describe('PoolAddress', () => {
let poolAddress: PoolAddressTest
const poolAddressTestFixture = async () => {
const poolAddressTestFactory = await ethers.getContractFactory('PoolAddressTest')
return (await poolAddressTestFactory.deploy()) as PoolAddressTest
}
let loadFixture: ReturnType<typeof waffle.createFixtureLoader>
before('create fixture loader', async () => {
loadFixture = waffle.createFixtureLoader(await (ethers as any).getSigners())
})
beforeEach('deploy PoolAddressTest', async () => {
poolAddress = await loadFixture(poolAddressTestFixture)
})
describe('#POOL_INIT_CODE_HASH', () => {
it('equals the hash of the pool bytecode', async () => {
expect(await poolAddress.POOL_INIT_CODE_HASH()).to.eq(POOL_BYTECODE_HASH)
})
})
describe('#computeAddress', () => {
it('all arguments equal zero', async () => {
await expect(poolAddress.computeAddress(constants.AddressZero, constants.AddressZero, constants.AddressZero, 0))
.to.be.reverted
})
it('matches example from core repo', async () => {
expect(
await poolAddress.computeAddress(
'0x5FbDB2315678afecb367f032d93F642f64180aa3',
'0x1000000000000000000000000000000000000000',
'0x2000000000000000000000000000000000000000',
250
)
).to.matchSnapshot()
})
it('token argument order cannot be in reverse', async () => {
await expect(
poolAddress.computeAddress(
'0x5FbDB2315678afecb367f032d93F642f64180aa3',
'0x2000000000000000000000000000000000000000',
'0x1000000000000000000000000000000000000000',
3000
)
).to.be.reverted
})
it('gas cost', async () => {
await snapshotGasCost(
poolAddress.getGasCostOfComputeAddress(
'0x5FbDB2315678afecb367f032d93F642f64180aa3',
'0x1000000000000000000000000000000000000000',
'0x2000000000000000000000000000000000000000',
3000
)
)
})
})
})