Skip to content

Commit

Permalink
Fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
proxima424 committed Oct 13, 2023
1 parent f27a163 commit ef8ca25
Show file tree
Hide file tree
Showing 2 changed files with 7,086 additions and 7,442 deletions.
104 changes: 71 additions & 33 deletions test/Smart-Account-Factory.specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,31 @@ describe("Smart Account Factory", async () => {
await setupTests();
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 600;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);
const depositInfo = await entryPoint.getDepositInfo(
smartAccountFactory.address
);
expect(depositInfo.stake).to.equal(stakeAmount);
});

// negative cases
it("reverts when wrong EntryPoint address is passed", async()=>{
it("reverts when wrong EntryPoint address is passed", async () => {
const { smartAccountFactory, smartAccountImplementation, entryPoint } =
await setupTests();
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 600;
const invalidEPAddress = AddressZero;
await expect(smartAccountFactory.addStake(invalidEPAddress, validUnstakeDelay, {
value: stakeAmount,
})).to.be.revertedWith("Invalid EP address");
await expect(
smartAccountFactory.addStake(invalidEPAddress, validUnstakeDelay, {
value: stakeAmount,
})
).to.be.revertedWith("Invalid EP address");
});

it("reverts when unstake delay not specified", async () => {
Expand Down Expand Up @@ -188,27 +194,37 @@ describe("Smart Account Factory", async () => {
// staking first
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 600;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);
// unstake
const tx = await smartAccountFactory.unlockStake(entryPoint.address);
await expect(tx).to.emit(entryPoint, "StakeUnlocked");
});

// negative cases
it("reverts when wrong EntryPoint address is passed ", async()=>{
it("reverts when wrong EntryPoint address is passed ", async () => {
const { smartAccountFactory, smartAccountImplementation, entryPoint } =
await setupTests();
// staking first
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 600;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);
// unstaking with wrong entryPoint address
const invalidEPAddress = AddressZero;
await expect(smartAccountFactory.unlockStake(invalidEPAddress)).to.be.revertedWith("Invalid EP address");
await expect(
smartAccountFactory.unlockStake(invalidEPAddress)
).to.be.revertedWith("Invalid EP address");
});

it("reverts when amount is not staked yet", async () => {
Expand All @@ -226,9 +242,13 @@ describe("Smart Account Factory", async () => {
// staking first
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 600;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);
// unstake()
await smartAccountFactory.unlockStake(entryPoint.address);
// calling unstake() again
Expand All @@ -247,9 +267,13 @@ describe("Smart Account Factory", async () => {
// staking first
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 1;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);

// Increase time (600 seconds)
// Mine additional blocks
Expand All @@ -269,16 +293,20 @@ describe("Smart Account Factory", async () => {
});

// negative cases
it("reverts when wrong EntryPoint address is passed ", async()=>{
it("reverts when wrong EntryPoint address is passed ", async () => {
const { smartAccountFactory, smartAccountImplementation, entryPoint } =
await setupTests();

// staking first
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 1;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);

// Increase time (600 seconds)
// Mine additional blocks
Expand All @@ -291,7 +319,9 @@ describe("Smart Account Factory", async () => {

// withdrawing with wrong entryPoint address
const invalidEPAddress = AddressZero;
await expect(smartAccountFactory.withdrawStake(invalidEPAddress,alice.address)).to.be.revertedWith("Invalid EP address");
await expect(
smartAccountFactory.withdrawStake(invalidEPAddress, alice.address)
).to.be.revertedWith("Invalid EP address");
});

it("reverts on empty stake withdraw", async () => {
Expand All @@ -309,9 +339,13 @@ describe("Smart Account Factory", async () => {
// staking first
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 1;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);

// waiting for additional blocks
const blocksToWait = 10;
Expand All @@ -332,9 +366,13 @@ describe("Smart Account Factory", async () => {
// staking first
const stakeAmount = ethers.utils.parseEther("1.234256");
const validUnstakeDelay = 600;
await smartAccountFactory.addStake(entryPoint.address, validUnstakeDelay, {
value: stakeAmount,
});
await smartAccountFactory.addStake(
entryPoint.address,
validUnstakeDelay,
{
value: stakeAmount,
}
);
// waiting for additional blocks
const blocksToWait = 10;
const currentBlockNumber = await ethers.provider.getBlockNumber();
Expand Down
Loading

0 comments on commit ef8ca25

Please sign in to comment.