Skip to content

Commit

Permalink
test(withdrawal.queue): add versioned test
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtamchik committed Feb 9, 2024
1 parent 6fa4bec commit 7b89536
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 40 deletions.
40 changes: 0 additions & 40 deletions test/0.8.9/withdrawalQueue.erc721.test.ts

This file was deleted.

49 changes: 49 additions & 0 deletions test/0.8.9/withdrawalQueue/deploy.ts
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,
};
}
23 changes: 23 additions & 0 deletions test/0.8.9/withdrawalQueue/withdrawalQueue.erc721.test.ts
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 test/0.8.9/withdrawalQueue/withdrawalQueue.versioned.test.ts
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,
},
],
});

0 comments on commit 7b89536

Please sign in to comment.