-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9249cc0
commit 319995c
Showing
4 changed files
with
98 additions
and
11 deletions.
There are no files selected for viewing
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
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
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,87 @@ | ||
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; | ||
import { ethers, upgrades } from "hardhat"; | ||
|
||
import { | ||
PoolsManager, | ||
RewardsBank, | ||
AirBond__factory, | ||
RewardsBank__factory, | ||
PoolsManager__factory, | ||
} from "../../../typechain-types"; | ||
|
||
import { expect } from "chai"; | ||
|
||
describe("PoolsManager", function () { | ||
let poolsManager: PoolsManager; | ||
let rewardsBank: RewardsBank; | ||
let tokenAddr: string; | ||
|
||
async function deploy() { | ||
const [owner] = await ethers.getSigners(); | ||
|
||
const rewardsBank = await new RewardsBank__factory(owner).deploy(); | ||
const airBond = await new AirBond__factory(owner).deploy(owner.address); | ||
|
||
const poolsManager = await new PoolsManager__factory(owner).deploy(rewardsBank.address); | ||
|
||
await (await rewardsBank.grantRole(await rewardsBank.DEFAULT_ADMIN_ROLE(), poolsManager.address)).wait(); | ||
const tokenAddr = airBond.address; | ||
|
||
return { poolsManager, rewardsBank, tokenAddr }; | ||
} | ||
|
||
beforeEach(async function () { | ||
({ poolsManager, rewardsBank, tokenAddr } = await loadFixture(deploy)); | ||
}); | ||
|
||
describe("Pool Management", function () { | ||
it("Should allow the owner to create a pool", async function () { | ||
const interest = 100000; // 10% | ||
const minStakeValue = 10; | ||
|
||
const tx = await poolsManager.createPool(tokenAddr, interest, minStakeValue); | ||
const receipt = await tx.wait(); | ||
const poolAddress = receipt.events![2].args!.pool; | ||
|
||
expect(await poolsManager.getPool(tokenAddr)).to.equal(poolAddress); | ||
}); | ||
|
||
it("Should activate and deactivate a pool", async function () { | ||
const interest = 100000; // 10% | ||
const minStakeValue = 10; | ||
|
||
const tx = await poolsManager.createPool(tokenAddr, interest, minStakeValue); | ||
const receipt = await tx.wait(); | ||
console.log(receipt.events); | ||
const poolAddress = receipt.events![2].args!.pool; | ||
|
||
await poolsManager.deactivatePool(poolAddress); | ||
expect(await poolsManager.getPoolInfo(poolAddress)).to.include(false); // Pool should be inactive | ||
|
||
await poolsManager.activatePool(poolAddress); | ||
expect(await poolsManager.getPoolInfo(poolAddress)).to.include(true); // Pool should be active | ||
}); | ||
|
||
it("Should allow the owner to set interest and min stake value", async function () { | ||
const interest = 100000; // 10% | ||
const minStakeValue = 10; | ||
|
||
const tx = await poolsManager.createPool(tokenAddr, interest, minStakeValue); | ||
const receipt = await tx.wait(); | ||
const poolAddress = receipt.events![2].args![0]; | ||
|
||
const newInterest = 300000; // 30% | ||
await poolsManager.setInterest(poolAddress, newInterest); | ||
const [,interestSet,,,] = await poolsManager.getPoolInfo(poolAddress); | ||
expect(interestSet).to.equal(newInterest); | ||
|
||
const newMinStakeValue = 20; | ||
await poolsManager.setMinStakeValue(poolAddress, newMinStakeValue); | ||
const [,,minStakeValueSet,,,] = await poolsManager.getPoolInfo(poolAddress); | ||
expect(minStakeValueSet).to.equal(newMinStakeValue); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
Empty file.