5
5
const { ethers } = require ( "hardhat" ) ;
6
6
const { anyValue } = require ( "@nomicfoundation/hardhat-chai-matchers/withArgs" ) ;
7
7
const { expect } = require ( "chai" ) ;
8
+ const { ZeroAddress } = require ( "ethers" ) ;
8
9
9
10
describe ( "Admins" , function ( ) {
10
11
let owner ;
@@ -15,12 +16,10 @@ describe("Admins", function () {
15
16
16
17
beforeEach ( async function ( ) {
17
18
const Admins = await ethers . getContractFactory ( "Admins" ) ;
18
-
19
+
19
20
[ owner , addr1 , addr2 , ...addrs ] = await ethers . getSigners ( ) ;
20
21
admins = await Admins . deploy ( owner . address ) ;
21
22
//adminsAdd = admins.target;
22
-
23
-
24
23
} ) ;
25
24
26
25
describe ( "Deployment" , function ( ) {
@@ -30,47 +29,49 @@ describe("Admins", function () {
30
29
} ) ;
31
30
32
31
describe ( "addAdmin" , function ( ) {
33
-
34
32
it ( "Should not be used without super privilegies" , async function ( ) {
35
- await expect ( admins . connect ( addr1 ) . addAdmin ( addr2 . address ) ) . to . be . revertedWith ( "not super admin" ) ;
33
+ await expect (
34
+ admins . connect ( addr1 ) . addAdmin ( addr2 . address )
35
+ ) . to . be . revertedWith ( "not super admin" ) ;
36
36
} ) ;
37
37
38
38
it ( "Should not downgrade a super admin" , async function ( ) {
39
- await expect ( admins . addAdmin ( owner . address ) ) . to . be . revertedWith ( "admin exists" ) ;
39
+ await expect ( admins . addAdmin ( owner . address ) ) . to . be . revertedWith (
40
+ "admin exists"
41
+ ) ;
40
42
} ) ;
41
43
42
44
it ( "Should fail if admin already exists" , async function ( ) {
43
45
await admins . addAdmin ( addr1 . address ) ;
44
- await expect ( admins . addAdmin ( addr1 . address ) ) . to . be . revertedWith ( "admin exists" ) ;
46
+ await expect ( admins . addAdmin ( addr1 . address ) ) . to . be . revertedWith (
47
+ "admin exists"
48
+ ) ;
45
49
} ) ;
46
50
47
51
it ( "Should setup adminRoles and adminsContracts" , async function ( ) {
48
52
await admins . addAdmin ( addr1 . address ) ;
49
- await expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( 1 ) ;
50
- await expect ( await admins . adminsContracts ( addr1 . address ) != 0 ) ;
51
- // todo : fix with the deployed contract
53
+ expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( 1 ) ;
54
+ expect ( await admins . adminsContracts ( addr1 . address ) ) . not . to . equal ( ZeroAddress ) ;
52
55
} ) ;
53
-
54
56
} ) ;
55
57
56
58
describe ( "removeAdmin" , function ( ) {
57
-
58
59
it ( "Should not be used without super privilegies" , async function ( ) {
59
- await expect ( admins . connect ( addr1 ) . removeAdmin ( addr2 . address ) ) . to . be . reverted ;
60
+ await expect ( admins . connect ( addr1 ) . removeAdmin ( addr2 . address ) ) . to . be
61
+ . reverted ;
60
62
} ) ;
61
63
62
64
it ( "Should clean adminRoles" , async function ( ) {
63
65
await admins . addAdmin ( addr1 . address ) ;
64
66
await admins . removeAdmin ( addr1 . address ) ;
65
- await expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( 0 ) ;
67
+ expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( ZeroAddress ) ;
66
68
} ) ;
67
-
68
69
} ) ;
69
70
70
71
describe ( "addSuperAdmin" , function ( ) {
71
-
72
72
it ( "Should not be used without super privilegies" , async function ( ) {
73
- await expect ( admins . connect ( addr1 ) . addSuperAdmin ( addr2 . address ) ) . to . be . reverted ;
73
+ await expect ( admins . connect ( addr1 ) . addSuperAdmin ( addr2 . address ) ) . to . be
74
+ . reverted ;
74
75
} ) ;
75
76
76
77
it ( "Should fail if superadmin already exists" , async function ( ) {
@@ -80,57 +81,50 @@ describe("Admins", function () {
80
81
81
82
it ( "Should setup adminRoles" , async function ( ) {
82
83
await admins . addSuperAdmin ( addr1 . address ) ;
83
- await expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( 2 ) ;
84
- // todo : fix with the deployed contract
84
+ await expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( 2 ) ;
85
+ // todo : fix with the deployed contract
85
86
} ) ;
86
-
87
87
} ) ;
88
88
89
89
describe ( "removeSuperAdmin" , function ( ) {
90
-
91
90
it ( "Should not be used without super privilegies" , async function ( ) {
92
- await expect ( admins . connect ( addr1 ) . removeSuperAdmin ( addr2 . address ) ) . to . be . reverted ;
91
+ await expect ( admins . connect ( addr1 ) . removeSuperAdmin ( addr2 . address ) ) . to . be
92
+ . reverted ;
93
93
} ) ;
94
94
95
95
it ( "Should clean adminRoles" , async function ( ) {
96
96
await admins . addSuperAdmin ( addr1 . address ) ;
97
97
await admins . removeSuperAdmin ( addr1 . address ) ;
98
- await expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( 0 ) ;
98
+ await expect ( await admins . adminRoles ( addr1 . address ) ) . to . equal ( 0 ) ;
99
99
} ) ;
100
-
101
100
} ) ;
102
101
103
-
104
-
105
102
describe ( "Events" , function ( ) {
106
-
107
103
it ( "Should emit an event on addAdmin" , async function ( ) {
108
104
await expect ( admins . addAdmin ( addr1 . address ) )
109
- . to . emit ( admins , ' Granted' )
110
- . withArgs ( owner . address , addr1 . address , 1 , anyValue ) ;
105
+ . to . emit ( admins , " Granted" )
106
+ . withArgs ( owner . address , addr1 . address , 1 , anyValue ) ;
111
107
} ) ;
112
108
113
109
it ( "Should emit an event on addSuperAdmin" , async function ( ) {
114
110
await expect ( admins . addSuperAdmin ( addr2 . address ) )
115
- . to . emit ( admins , ' Granted' )
116
- . withArgs ( owner . address , addr2 . address , 2 , anyValue ) ;
111
+ . to . emit ( admins , " Granted" )
112
+ . withArgs ( owner . address , addr2 . address , 2 , anyValue ) ;
117
113
} ) ;
114
+ } ) ;
118
115
116
+ // describe("Transfers", function () {
117
+ // it("Should transfer the funds to the owner", async function () {
118
+ // const { lock, unlockTime, lockedAmount, owner } = await loadFixture(
119
+ // deployOneYearLockFixture
120
+ // );
119
121
120
- } )
121
-
122
- // describe("Transfers", function () {
123
- // it("Should transfer the funds to the owner", async function () {
124
- // const { lock, unlockTime, lockedAmount, owner } = await loadFixture(
125
- // deployOneYearLockFixture
126
- // );
127
-
128
- // await time.increaseTo(unlockTime);
122
+ // await time.increaseTo(unlockTime);
129
123
130
- // await expect(lock.withdraw()).to.changeEtherBalances(
131
- // [owner, lock],
132
- // [lockedAmount, -lockedAmount]
133
- // );
134
- // });
135
- // });
124
+ // await expect(lock.withdraw()).to.changeEtherBalances(
125
+ // [owner, lock],
126
+ // [lockedAmount, -lockedAmount]
127
+ // );
128
+ // });
129
+ // });
136
130
} ) ;
0 commit comments