-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(withdrawal.queue): add versioned test
- Loading branch information
1 parent
6fa4bec
commit 7b89536
Showing
4 changed files
with
97 additions
and
40 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ethers } from "hardhat"; | ||
|
||
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"; | ||
|
||
import { ether } from "lib"; | ||
|
||
const QUEUE_NAME = "Lido: Withdrawal Request NFT"; | ||
const QUEUE_SYMBOL = "unstETH"; | ||
|
||
interface MinimumWithdrawalQueueDeploymentParams { | ||
owner: HardhatEthersSigner; | ||
name?: string; | ||
symbol?: string; | ||
} | ||
|
||
export default async function deployMinimumWithdrawalQueue({ | ||
owner, | ||
name = QUEUE_NAME, | ||
symbol = QUEUE_SYMBOL, | ||
}: MinimumWithdrawalQueueDeploymentParams) { | ||
const initialTotalSupply = ether("1.0"); | ||
const holderStEth = ether("99.0"); | ||
|
||
const stEth = await ethers.deployContract("StETHPermitMock", { | ||
value: initialTotalSupply, | ||
}); | ||
|
||
await stEth.mintSteth(owner, { value: holderStEth }); | ||
|
||
const stEthAddress = await stEth.getAddress(); | ||
const wstEth = await ethers.deployContract("WstETHMock", [stEthAddress]); | ||
|
||
const wstEthAddress = await wstEth.getAddress(); | ||
|
||
const token = await ethers.deployContract("WithdrawalQueueERC721", [wstEthAddress, name, symbol]); | ||
|
||
await stEth.connect(owner).approve(await token.getAddress(), holderStEth); | ||
await token.connect(owner).requestWithdrawals([holderStEth], owner); | ||
|
||
const ownerTokenId = await token.getLastRequestId(); | ||
|
||
return { | ||
token, | ||
name, | ||
symbol, | ||
owner, | ||
ownerTokenId, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ethers } from "hardhat"; | ||
|
||
import { testERC721Compliance } from "../../common/erc721.test"; | ||
|
||
import deployMinimumWithdrawalQueue from "./deploy"; | ||
|
||
testERC721Compliance({ | ||
tokenName: "WithdrawalQueue NFT", | ||
deploy: async () => { | ||
const signers = await ethers.getSigners(); | ||
const owner = signers[signers.length - 1]; | ||
|
||
const deployed = await deployMinimumWithdrawalQueue({ owner }); | ||
|
||
return { | ||
token: deployed.token, | ||
name: deployed.name, | ||
symbol: deployed.symbol, | ||
holder: deployed.owner, | ||
holderTokenId: deployed.ownerTokenId, | ||
}; | ||
}, | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/0.8.9/withdrawalQueue/withdrawalQueue.versioned.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ethers } from "hardhat"; | ||
|
||
import { WithdrawalQueueERC721__factory } from "typechain-types"; | ||
|
||
import { randomAddress } from "lib"; | ||
|
||
import { testVersionedCompliance } from "../../common/versioned.test"; | ||
|
||
import deployMinimumWithdrawalQueue from "./deploy"; | ||
|
||
testVersionedCompliance({ | ||
name: "WithdrawalQueue Versioned", | ||
deploy: async () => { | ||
const signers = await ethers.getSigners(); | ||
const owner = signers[signers.length - 1]; | ||
const deployed = await deployMinimumWithdrawalQueue({ owner }); | ||
return deployed.token; | ||
}, | ||
updates: [ | ||
{ | ||
call: WithdrawalQueueERC721__factory.createInterface().encodeFunctionData("initialize", [randomAddress()]), | ||
version: 1n, | ||
}, | ||
], | ||
}); |