-
Notifications
You must be signed in to change notification settings - Fork 0
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
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const { expect } = require('chai'); | ||
const { web3 } = require('@openzeppelin/test-helpers/src/setup'); | ||
const { BN } = web3.utils; | ||
|
||
const Reserve = artifacts.require('Reserve'); | ||
|
||
contract('Reserve', (accounts) => { | ||
const [owner, user1, user2] = accounts; | ||
|
||
beforeEach(async () => { | ||
this.reserve = await Reserve.new({ from: owner }); | ||
}); | ||
|
||
describe('Initialization', () => { | ||
it('should have an initial reserve ratio of 20%', async () => { | ||
const reserveRatio = await this.reserve.reserveRatio(); | ||
expect(reserveRatio).to.be.bignumber.equal(new BN('200000000000000000', 10)); | ||
}); | ||
}); | ||
|
||
describe('Deposit', () => { | ||
it('should allow the owner to deposit tokens into the reserve', async () => { | ||
await this.reserve.deposit(new BN('100', 10), { from: owner }); | ||
const reserveBalance = await this.reserve.balance(); | ||
expect(reserveBalance).to.be.bignumber.equal(new BN('100', 10)); | ||
}); | ||
|
||
it('should not allow user1 to deposit tokens into the reserve', async () => { | ||
await expectRevert( | ||
this.reserve.deposit(new BN('100', 10), { from: user1 }), | ||
'Only the owner can deposit tokens into the reserve' | ||
); | ||
}); | ||
}); | ||
|
||
describe('Withdrawal', () => { | ||
it('should allow the owner to withdraw tokens from the reserve', async () => { | ||
await this.reserve.withdraw(new BN('50', 10), { from: owner }); | ||
const reserveBalance = await this.reserve.balance(); | ||
expect(reserveBalance).to.be.bignumber.equal(new BN('50', 10)); | ||
}); | ||
|
||
it('should not allow user1 to withdraw tokens from the reserve', async () => { | ||
await expectRevert( | ||
this.reserve.withdraw(new BN('50', 10), { from: user1 }), | ||
'Only the owner can withdraw tokens from the reserve' | ||
); | ||
}); | ||
}); | ||
}); |