Skip to content

Commit

Permalink
prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jferas committed Sep 26, 2024
1 parent a49d84c commit 862aee8
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 349 deletions.
70 changes: 30 additions & 40 deletions test/Comp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Comp", function () {
const { otherAccount, comp } = await loadFixture(deployFixtures);

await expect(
comp.approve(otherAccount, ethers.MaxUint256 - 1n)
comp.approve(otherAccount, ethers.MaxUint256 - 1n),
).to.be.revertedWith("Comp::approve: amount exceeds 96 bits");
});

Expand All @@ -42,11 +42,11 @@ describe("Comp", function () {
.withArgs(owner.address, otherAccount.address, 2n ** 96n - 1n);

await expect(
comp.connect(otherAccount).transferFrom(owner, otherAccount, 100)
comp.connect(otherAccount).transferFrom(owner, otherAccount, 100),
).to.not.emit(comp, "Approval");

expect(await comp.allowance(owner, otherAccount)).to.equal(
2n ** 96n - 1n
2n ** 96n - 1n,
);
});
});
Expand All @@ -62,7 +62,7 @@ describe("Comp", function () {
it("Error: over uint96", async function () {
const { otherAccount, comp } = await loadFixture(deployFixtures);
await expect(
comp.transfer(otherAccount, ethers.MaxUint256 - 1n)
comp.transfer(otherAccount, ethers.MaxUint256 - 1n),
).to.be.revertedWith("Comp::transfer: amount exceeds 96 bits");
});
});
Expand All @@ -72,7 +72,7 @@ describe("Comp", function () {
const { owner, otherAccount, comp } = await loadFixture(deployFixtures);
await comp.approve(otherAccount, 100);
await expect(
comp.connect(otherAccount).transferFrom(owner, otherAccount, 100)
comp.connect(otherAccount).transferFrom(owner, otherAccount, 100),
)
.to.emit(comp, "Transfer")
.withArgs(owner.address, otherAccount.address, 100)
Expand All @@ -86,7 +86,7 @@ describe("Comp", function () {
await expect(
comp
.connect(otherAccount)
.transferFrom(owner, otherAccount, ethers.MaxUint256 - 1n)
.transferFrom(owner, otherAccount, ethers.MaxUint256 - 1n),
).to.be.revertedWith("Comp::approve: amount exceeds 96 bits");
});
});
Expand All @@ -95,25 +95,25 @@ describe("Comp", function () {
it("Error: from zero address", async function () {
const { otherAccount, comp } = await loadFixture(deployFixtures);
await expect(
comp.transferFrom(ethers.ZeroAddress, otherAccount, 0)
comp.transferFrom(ethers.ZeroAddress, otherAccount, 0),
).to.be.revertedWith(
"Comp::_transferTokens: cannot transfer from the zero address"
"Comp::_transferTokens: cannot transfer from the zero address",
);
});

it("Error: to zero address", async function () {
const { comp } = await loadFixture(deployFixtures);
await expect(comp.transfer(ethers.ZeroAddress, 100)).to.be.revertedWith(
"Comp::_transferTokens: cannot transfer to the zero address"
"Comp::_transferTokens: cannot transfer to the zero address",
);
});

it("Error: exceeds balance", async function () {
const { comp, owner, otherAccount } = await loadFixture(deployFixtures);
await expect(
comp.connect(otherAccount).transfer(owner, 100)
comp.connect(otherAccount).transfer(owner, 100),
).to.be.revertedWith(
"Comp::_transferTokens: transfer amount exceeds balance"
"Comp::_transferTokens: transfer amount exceeds balance",
);
});
});
Expand All @@ -126,7 +126,7 @@ describe("Comp", function () {
.withArgs(owner.address, ethers.ZeroAddress, owner.address);
expect(await comp.delegates(owner)).to.eq(owner.address);
expect(await comp.getCurrentVotes(owner)).to.eq(
BigInt("10000000") * 10n ** 18n
BigInt("10000000") * 10n ** 18n,
);
});

Expand All @@ -135,9 +135,7 @@ describe("Comp", function () {
const { comp, owner } = await loadFixture(deployFixtures);
const domain = await getTypedDomainComp(
comp,
(
await ethers.provider.getNetwork()
).chainId
(await ethers.provider.getNetwork()).chainId,
);
const delegationTypes = await getDelegationTypes();

Expand All @@ -157,8 +155,8 @@ describe("Comp", function () {
(await time.latest()) + 100,
v,
r,
s
)
s,
),
)
.to.emit(comp, "DelegateChanged")
.withArgs(owner.address, ethers.ZeroAddress, owner.address);
Expand All @@ -168,9 +166,7 @@ describe("Comp", function () {
const { comp, owner, otherAccount } = await loadFixture(deployFixtures);
const domain = await getTypedDomainComp(
comp,
(
await ethers.provider.getNetwork()
).chainId
(await ethers.provider.getNetwork()).chainId,
);
const delegationTypes = await getDelegationTypes();

Expand All @@ -189,7 +185,7 @@ describe("Comp", function () {
(await time.latest()) + 100,
v,
r,
s
s,
);

sig = await owner.signTypedData(domain, delegationTypes, {
Expand All @@ -202,17 +198,15 @@ describe("Comp", function () {
v = "0x" + sig.substring(130, 132);

await expect(
comp.delegateBySig(otherAccount.address, 2, 0, v, r, s)
comp.delegateBySig(otherAccount.address, 2, 0, v, r, s),
).to.be.revertedWith("Comp::delegateBySig: invalid nonce");
});

it("Error: invalid signature", async function () {
const { comp, owner } = await loadFixture(deployFixtures);
const domain = await getTypedDomainComp(
comp,
(
await ethers.provider.getNetwork()
).chainId
(await ethers.provider.getNetwork()).chainId,
);
const delegationTypes = await getDelegationTypes();

Expand All @@ -232,18 +226,16 @@ describe("Comp", function () {
(await time.latest()) + 100,
v,
r,
s
)
s,
),
).to.revertedWith("Comp::delegateBySig: invalid signature");
});

it("Error: expired", async function () {
const { comp, owner } = await loadFixture(deployFixtures);
const domain = await getTypedDomainComp(
comp,
(
await ethers.provider.getNetwork()
).chainId
(await ethers.provider.getNetwork()).chainId,
);
const delegationTypes = await getDelegationTypes();

Expand All @@ -263,8 +255,8 @@ describe("Comp", function () {
(await time.latest()) - 100,
v,
r,
s
)
s,
),
).to.be.revertedWith("Comp::delegateBySig: signature expired");
});
});
Expand Down Expand Up @@ -298,7 +290,7 @@ describe("Comp", function () {
expect(await comp.getPriorVotes(otherAccount, blockNumber1)).to.eq(0);
expect(await comp.getPriorVotes(otherAccount, blockNumber2)).to.eq(200);
expect(await comp.getPriorVotes(otherAccount, blockNumber3 - 1)).to.eq(
200
200,
);
expect(await comp.getPriorVotes(otherAccount, blockNumber3)).to.eq(400);
});
Expand All @@ -315,7 +307,7 @@ describe("Comp", function () {
const blockNumber = await ethers.provider.getBlockNumber();

await expect(comp.getPriorVotes(owner, blockNumber)).to.be.revertedWith(
"Comp::getPriorVotes: not yet determined"
"Comp::getPriorVotes: not yet determined",
);
});
});
Expand All @@ -333,7 +325,7 @@ describe("Comp", function () {
.withArgs(
owner.address,
10000000n * 10n ** 18n,
10000000n * 10n ** 18n - 100n
10000000n * 10n ** 18n - 100n,
);
});

Expand All @@ -353,9 +345,7 @@ describe("Comp", function () {

const domain = await getTypedDomainComp(
comp,
(
await ethers.provider.getNetwork()
).chainId
(await ethers.provider.getNetwork()).chainId,
);
const delegationTypes = await getDelegationTypes();

Expand Down Expand Up @@ -385,7 +375,7 @@ describe("Comp", function () {
expiry,
v,
r,
s
s,
)
).data;

Expand All @@ -396,7 +386,7 @@ describe("Comp", function () {
expiry,
v2,
r2,
s2
s2,
)
).data;

Expand Down
38 changes: 17 additions & 21 deletions test/ForkTestSimulateUpgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ describe("ForkTestSimulateUpgrade", function () {

const comp = await ethers.getContractAt(
"Comp",
"0xc00e94Cb662C3520282E6f5717214004A7f26888"
"0xc00e94Cb662C3520282E6f5717214004A7f26888",
);
const governorBravoDelegator = await ethers.getContractAt(
"GovernorBravoDelegate",
"0xc0Da02939E1441F497fd74F78cE7Decb17B66529"
"0xc0Da02939E1441F497fd74F78cE7Decb17B66529",
);
const proposingSigner = await ethers.getSigner(
"0x2775b1c75658Be0F640272CCb8c72ac986009e38"
"0x2775b1c75658Be0F640272CCb8c72ac986009e38",
);
await hardhat.network.provider.send("hardhat_setBalance", [
proposingSigner.address,
Expand All @@ -40,7 +40,7 @@ describe("ForkTestSimulateUpgrade", function () {
await impersonateAccount(await proposingSigner.getAddress());
await comp.connect(proposingSigner).delegate(proposingSigner);
const NewImplementation = await ethers.getContractFactory(
"GovernorBravoDelegate"
"GovernorBravoDelegate",
);
const newImplementation = await NewImplementation.deploy();

Expand All @@ -55,7 +55,7 @@ describe("ForkTestSimulateUpgrade", function () {
.encode(["address"], [await newImplementation.getAddress()])
.slice(2),
],
"Upgrade Governance"
"Upgrade Governance",
);

return { comp, governorBravoDelegator, proposingSigner };
Expand Down Expand Up @@ -98,23 +98,22 @@ describe("ForkTestSimulateUpgrade", function () {
it("validate storage fields", async function () {
const { governorBravoDelegator } = await loadFixture(deployFixtures);
expect(await governorBravoDelegator.admin()).to.equal(
"0x6d903f6003cca6255D85CcA4D3B5E5146dC33925"
"0x6d903f6003cca6255D85CcA4D3B5E5146dC33925",
);
expect(await governorBravoDelegator.pendingAdmin()).to.equal(
ethers.ZeroAddress
ethers.ZeroAddress,
);
expect(await governorBravoDelegator.comp()).to.equal(
"0xc00e94Cb662C3520282E6f5717214004A7f26888"
"0xc00e94Cb662C3520282E6f5717214004A7f26888",
);
expect(await governorBravoDelegator.timelock()).to.equal(
"0x6d903f6003cca6255D85CcA4D3B5E5146dC33925"
"0x6d903f6003cca6255D85CcA4D3B5E5146dC33925",
);
});

it("Grant COMP proposal", async function () {
const { comp, governorBravoDelegator, proposingSigner } = await loadFixture(
deployFixtures
);
const { comp, governorBravoDelegator, proposingSigner } =
await loadFixture(deployFixtures);
const [signer] = await ethers.getSigners();
const comptrollerAddress = "0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B";
const grantCompSelector = ethers
Expand All @@ -131,16 +130,15 @@ describe("ForkTestSimulateUpgrade", function () {
[comptrollerAddress],
[0],
[grantCompData],
"Grant COMP"
"Grant COMP",
);

expect(await comp.balanceOf(signer.address)).to.equal(10000);
});

it("Cast vote by sig with reason", async function () {
const { comp, governorBravoDelegator, proposingSigner } = await loadFixture(
deployFixtures
);
const { comp, governorBravoDelegator, proposingSigner } =
await loadFixture(deployFixtures);
const [signer, otherSigner] = await ethers.getSigners();
await comp.delegate(signer);
await comp.connect(proposingSigner).transfer(signer.address, 1000);
Expand All @@ -149,14 +147,12 @@ describe("ForkTestSimulateUpgrade", function () {
[governorBravoDelegator],
[0],
["0x"],
"Test Proposal"
"Test Proposal",
);

const domain = await getTypedDomain(
governorBravoDelegator,
(
await ethers.provider.getNetwork()
).chainId
(await ethers.provider.getNetwork()).chainId,
);

const sig = await signer.signTypedData(domain, getVoteWithReasonTypes(), {
Expand All @@ -171,7 +167,7 @@ describe("ForkTestSimulateUpgrade", function () {
await expect(
governorBravoDelegator
.connect(otherSigner)
.castVoteWithReasonBySig(proposalId, 1, "Great Idea!", v, r, s)
.castVoteWithReasonBySig(proposalId, 1, "Great Idea!", v, r, s),
)
.to.emit(governorBravoDelegator, "VoteCast")
.withArgs(signer.address, proposalId, 1, BigInt("1000"), "Great Idea!");
Expand Down
Loading

0 comments on commit 862aee8

Please sign in to comment.