Skip to content

Commit

Permalink
Create PiUSDTreasury.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 14, 2024
1 parent 35be1d5 commit 2c93440
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { expect } = require('chai');
const { ethers } = require('hardhat');

describe('PiUSDTreasury', function () {
let piUSDTreasury;
let owner;
let user1;
let user2;

beforeEach(async function () {
[owner, user1, user2] = await ethers.getSigners();
piUSDTreasury = await ethers.getContractFactory('PiUSDTreasury');
piUSDTreasury = await piUSDTreasury.deploy();
});

it('should have a treasury manager', async function () {
expect(await piUSDTreasury.treasuryManager()).to.equal(owner.address);
});

it('should fund treasury correctly', async function () {
await piUSDTreasury.fundTreasury(ethers.utils.parseEther('100'));
expect(await piUSDTreasury.treasuryBalance()).to.equal(ethers.utils.parseEther('100'));
});

it('should withdraw from treasury correctly', async function () {
await piUSDTreasury.fundTreasury(ethers.utils.parseEther('100'));
await piUSDTreasury.withdrawFromTreasury(ethers.utils.parseEther('50'));
expect(await piUSDTreasury.treasuryBalance()).to.equal(ethers.utils.parseEther('50'));
});

it('should update interest rate correctly', async function () {
await piUSDTreasury.updateInterestRate(ethers.utils.parseEther('0.05'));
expect(await piUSDTreasury.interestRate()).to.equal(ethers.utils.parseEther('0.05'));
});

it('should update reserve ratio correctly', async function () {
await piUSDTreasury.updateReserveRatio(ethers.utils.parseEther('0.2'));
expect(await piUSDTreasury.reserveRatio()).to.equal(ethers.utils.parseEther('0.2'));
});
});

0 comments on commit 2c93440

Please sign in to comment.