Skip to content

Commit

Permalink
add pause leave party test
Browse files Browse the repository at this point in the history
  • Loading branch information
YouStillAlive committed Aug 28, 2024
1 parent bdb532b commit 9693212
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
18 changes: 17 additions & 1 deletion test/BNBPartyFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,22 @@ describe("BNBPartyFactory", function () {
await bnbPartyFactory.unpause()
})

it("should revert leave party if paused", async function () {
await bnbPartyFactory.createParty(name, symbol, { value: tokenCreationFee })
const tokenId = (await BNBPositionManager.totalSupply()) - 1n
const position = await BNBPositionManager.positions(tokenId)
const MEME = position.token1 == (await weth9.getAddress()) ? position.token0 : position.token1
const MEMEToken = await ethers.getContractAt("ERC20Token", MEME)
await MEMEToken.approve(await bnbPartyFactory.getAddress(), ethers.parseEther("1000000"))
await bnbPartyFactory.joinParty(MEME, 0, { value: tokenCreationFee })
await bnbPartyFactory.pause()
await expect(bnbPartyFactory.leaveParty(MEME, tokenCreationFee, 0)).to.be.revertedWithCustomError(
bnbPartyFactory,
"EnforcedPause"
)
await bnbPartyFactory.unpause()
})

describe("Second Liquidity Pool", function () {
let MEME: string
let tokenId: string
Expand Down Expand Up @@ -193,7 +209,7 @@ describe("BNBPartyFactory", function () {
const newBalance = await token.balanceOf(newLPPool)
const userBalance = await token.balanceOf(await signers[0].getAddress())
const totalSupply = await token.totalSupply()
expect(newBalance).to.be.equal(totalSupply - userBalance - oldPoolBalance)
expect(newBalance).to.be.equal(totalSupply - userBalance - oldPoolBalance)
})
})
})
8 changes: 4 additions & 4 deletions test/WithdrawFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe("Withdraw fees", function () {
const lpPool = (await ethers.getContractAt("UniswapV3Pool", lpAddress)) as any as IUniswapV3Pool
const liquidity = await lpPool.liquidity()
const feeGrowthGlobalX128 = await lpPool.feeGrowthGlobal1X128() > 0 ? await lpPool.feeGrowthGlobal1X128() : await lpPool.feeGrowthGlobal0X128()
expect(await bnbPartyFactory.calculateFees(liquidity, feeGrowthGlobalX128)).to.be.equal(amountIn / 100n - 1n) // 1 % fee
expect(await bnbPartyFactory.calculateFees(liquidity, feeGrowthGlobalX128)).to.be.equal(amountIn / 100n) // 1 % fee
})

it("calculateFees should return fee from 5 swaps", async () => {
Expand All @@ -99,11 +99,11 @@ describe("Withdraw fees", function () {
const lpPool = (await ethers.getContractAt("UniswapV3Pool", lpAddress)) as any as IUniswapV3Pool
const liquidity = await lpPool.liquidity()
const feeGrowthGlobalX128 = await lpPool.feeGrowthGlobal0X128() > 0 ? await lpPool.feeGrowthGlobal0X128() : await lpPool.feeGrowthGlobal1X128()
expect(await bnbPartyFactory.calculateFees(liquidity, feeGrowthGlobalX128)).to.be.equal(amountIn / 20n) // 1 % fee
expect(await bnbPartyFactory.calculateFees(liquidity, feeGrowthGlobalX128)).to.be.equal(amountIn / 20n - 1n) // 1 % fee
})

it("isToken0WBNB should return true if token0 is WBNB", async () => {
expect(await bnbPartyFactory.isToken0WBNB(lpAddress)).to.be.true
it("isToken0WBNB should return false if token0 is not WBNB", async () => {
expect(await bnbPartyFactory.isToken0WBNB(lpAddress)).to.be.false
})

it("isToken0WBNB should revert if set zero address", async () => {
Expand Down

0 comments on commit 9693212

Please sign in to comment.