|
1 |
| -import { expect } from 'chai'; |
2 |
| -import { ethers } from 'hardhat'; |
3 |
| -import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers'; |
4 |
| -import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'; |
5 |
| -import { RIFToken } from '../typechain-types'; |
| 1 | +import { expect } from 'chai' |
| 2 | +import { ethers } from 'hardhat' |
| 3 | +import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers' |
| 4 | +import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers' |
| 5 | +import { RIFToken } from '../typechain-types' |
6 | 6 |
|
7 | 7 | describe('RIFToken Contract', function () {
|
8 |
| - let owner: SignerWithAddress, addr1: SignerWithAddress, addr2: SignerWithAddress; |
9 |
| - let rifToken: RIFToken; |
| 8 | + let owner: SignerWithAddress, addr1: SignerWithAddress, addr2: SignerWithAddress |
| 9 | + let rifToken: RIFToken |
10 | 10 |
|
11 |
| - const deployRif = () => ethers.deployContract('RIFToken'); |
| 11 | + const deployRif = () => ethers.deployContract('RIFToken') |
12 | 12 |
|
13 | 13 | before(async () => {
|
14 |
| - [owner, addr1, addr2] = await ethers.getSigners(); |
15 |
| - rifToken = await loadFixture(deployRif); |
16 |
| - }); |
| 14 | + ;[owner, addr1, addr2] = await ethers.getSigners() |
| 15 | + rifToken = await loadFixture(deployRif) |
| 16 | + }) |
17 | 17 |
|
18 | 18 | it('Should assign the initial balance to the contract itself', async function () {
|
19 |
| - const contractBalance = await rifToken.balanceOf(rifToken); |
20 |
| - expect(contractBalance).to.equal(ethers.parseUnits('1000000000', 18)); |
21 |
| - }); |
| 19 | + const contractBalance = await rifToken.balanceOf(rifToken) |
| 20 | + expect(contractBalance).to.equal(ethers.parseUnits('1000000000', 18)) |
| 21 | + }) |
22 | 22 |
|
23 | 23 | it('Should use validAddress', async function () {
|
24 |
| - const addressOne = await addr1.getAddress(); |
25 |
| - const isAddressOneValid = await rifToken.validAddress(addressOne); |
26 |
| - expect(isAddressOneValid).to.be.true; |
27 |
| - }); |
| 24 | + const addressOne = await addr1.getAddress() |
| 25 | + const isAddressOneValid = await rifToken.validAddress(addressOne) |
| 26 | + expect(isAddressOneValid).to.be.true |
| 27 | + }) |
28 | 28 |
|
29 | 29 | // Single block to test the entire Transfer flow
|
30 | 30 |
|
31 | 31 | it('Should transfer all the tokens to deployer/owner using setAuthorizedManagerContract', async function () {
|
32 |
| - await rifToken.setAuthorizedManagerContract(owner); |
| 32 | + await rifToken.setAuthorizedManagerContract(owner) |
33 | 33 |
|
34 |
| - expect(await rifToken.balanceOf(owner)).to.be.equal(ethers.parseUnits('1000000000', 'ether')); |
35 |
| - }); |
| 34 | + expect(await rifToken.balanceOf(owner)).to.be.equal(ethers.parseUnits('1000000000', 'ether')) |
| 35 | + }) |
36 | 36 |
|
37 | 37 | it('Should transfer tokens between accounts', async function () {
|
38 | 38 | // Close distribution
|
39 |
| - const latestBlock = await ethers.provider.getBlock('latest'); |
| 39 | + const latestBlock = await ethers.provider.getBlock('latest') |
40 | 40 |
|
41 | 41 | if (latestBlock) {
|
42 | 42 | // We must close tokenDistribution to send transactions
|
43 |
| - await rifToken.closeTokenDistribution(latestBlock.timestamp); |
| 43 | + await rifToken.closeTokenDistribution(latestBlock.timestamp) |
44 | 44 |
|
45 | 45 | // Transfer 50 RIF Tokens to address 1
|
46 |
| - await rifToken.transfer(addr1, ethers.parseUnits('50', 'ether')); |
47 |
| - const addr1Balance = await rifToken.balanceOf(addr1); |
48 |
| - expect(addr1Balance).to.equal(ethers.parseUnits('50', 'ether')); |
| 46 | + await rifToken.transfer(addr1, ethers.parseUnits('50', 'ether')) |
| 47 | + const addr1Balance = await rifToken.balanceOf(addr1) |
| 48 | + expect(addr1Balance).to.equal(ethers.parseUnits('50', 'ether')) |
49 | 49 |
|
50 | 50 | // Transfer 10 RIF Tokens from address 1 to address 2
|
51 |
| - await rifToken.connect(addr1).transfer(addr2, ethers.parseUnits('10', 'ether')); |
52 |
| - const addr2Balance = await rifToken.balanceOf(addr2); |
53 |
| - expect(addr2Balance).to.equal(ethers.parseUnits('10', 'ether')); |
| 51 | + await rifToken.connect(addr1).transfer(addr2, ethers.parseUnits('10', 'ether')) |
| 52 | + const addr2Balance = await rifToken.balanceOf(addr2) |
| 53 | + expect(addr2Balance).to.equal(ethers.parseUnits('10', 'ether')) |
54 | 54 | }
|
55 |
| - }); |
| 55 | + }) |
56 | 56 |
|
57 | 57 | it('Should make sure that the "Transfer" event is emitted', async () => {
|
58 | 58 | // Also check that the event "Transfer" is emitted
|
59 | 59 | await expect(rifToken.transfer(addr1, 1))
|
60 | 60 | .to.emit(rifToken, 'Transfer(address,address,uint256)')
|
61 |
| - .withArgs(owner, addr1, 1); |
62 |
| - }); |
63 |
| -}); |
| 61 | + .withArgs(owner, addr1, 1) |
| 62 | + }) |
| 63 | +}) |
0 commit comments