-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
blockchain_integration/pi_network/pi-stablecoin/tests/PiUSDTreasury.test.js
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,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')); | ||
}); | ||
}); |