@@ -20,6 +20,7 @@ describe("Installer", function () {
20
20
let owner : SignerWithAddress ;
21
21
let target : SignerWithAddress ;
22
22
let cloneDistributionId : any ;
23
+ let distributorsId : any ;
23
24
let installer : MockInstaller ;
24
25
25
26
beforeEach ( async function ( ) {
@@ -47,6 +48,10 @@ describe("Installer", function () {
47
48
distributor
48
49
. connect ( owner )
49
50
. addDistribution ( cloneDistributionId , ethers . utils . formatBytes32String ( "" ) ) ;
51
+ distributorsId = ethers . utils . solidityKeccak256 (
52
+ [ "bytes32" , "bytes32" ] ,
53
+ [ cloneDistributionId , ethers . utils . formatBytes32String ( "" ) ]
54
+ ) ;
50
55
const Installer = ( await ethers . getContractFactory ( "MockInstaller" ) ) as MockInstaller__factory ;
51
56
installer = await Installer . deploy ( target . address , owner . address ) ;
52
57
} ) ;
@@ -78,7 +83,7 @@ describe("Installer", function () {
78
83
await installer . connect ( owner ) . whitelistDistributor ( distributor . address ) ;
79
84
80
85
expect (
81
- await installer . connect ( deployer ) . install ( distributor . address , cloneDistributionId , "0x" )
86
+ await installer . connect ( deployer ) . install ( distributor . address , distributorsId , "0x" )
82
87
) . to . emit ( installer , "Installed" ) ;
83
88
} ) ;
84
89
it ( "can List distributors" , async function ( ) {
@@ -89,7 +94,7 @@ describe("Installer", function () {
89
94
} ) ;
90
95
it ( "Can get instances by id" , async function ( ) {
91
96
await installer . connect ( owner ) . whitelistDistributor ( distributor . address ) ;
92
- await installer . connect ( owner ) . install ( distributor . address , cloneDistributionId , "0x" ) ;
97
+ await installer . connect ( owner ) . install ( distributor . address , distributorsId , "0x" ) ;
93
98
const instanceNum = await installer . connect ( owner ) . getInstancesNum ( ) ;
94
99
expect ( ( await installer . connect ( owner ) . getInstance ( instanceNum ) ) . length ) . to . be . eq ( 1 ) ;
95
100
let instanceAddress = ( await installer . connect ( owner ) . getInstance ( instanceNum ) ) [ 0 ] ;
@@ -103,7 +108,7 @@ describe("Installer", function () {
103
108
104
109
it ( "Allows whitelisted distributor only valid instances to call target" , async ( ) => {
105
110
await installer . connect ( owner ) . whitelistDistributor ( distributor . address ) ;
106
- await installer . connect ( owner ) . install ( distributor . address , cloneDistributionId , "0x" ) ;
111
+ await installer . connect ( owner ) . install ( distributor . address , distributorsId , "0x" ) ;
107
112
const instanceNum = await installer . connect ( owner ) . getInstancesNum ( ) ;
108
113
let instanceAddress = ( await installer . connect ( target ) . getInstance ( instanceNum ) ) [ 0 ] ;
109
114
await expect (
@@ -114,15 +119,15 @@ describe("Installer", function () {
114
119
installer . connect ( target ) . beforeCall ( "0x" , "0x00000000" , instanceAddress , "0" , "0x" )
115
120
) . to . be . not . revertedWithCustomError ( installer , "NotAnInstance" ) ;
116
121
117
- await distributor . connect ( owner ) . removeDistribution ( cloneDistributionId ) ;
122
+ await distributor . connect ( owner ) . removeDistribution ( distributorsId ) ;
118
123
await expect (
119
124
installer . connect ( target ) . beforeCall ( "0x" , "0x00000000" , instanceAddress , "0" , "0x" )
120
125
) . to . be . revertedWithCustomError ( distributor , "InvalidInstance" ) ;
121
126
} ) ;
122
127
123
128
it ( "Allows valid distributions added by distributor and distribution id to call target" , async ( ) => {
124
- await installer . connect ( owner ) . allowDistribution ( distributor . address , cloneDistributionId ) ;
125
- await installer . connect ( owner ) . install ( distributor . address , cloneDistributionId , "0x" ) ;
129
+ await installer . connect ( owner ) . allowDistribution ( distributor . address , distributorsId ) ;
130
+ await installer . connect ( owner ) . install ( distributor . address , distributorsId , "0x" ) ;
126
131
const instanceNum = await installer . connect ( owner ) . getInstancesNum ( ) ;
127
132
let instanceAddress = ( await installer . connect ( target ) . getInstance ( instanceNum ) ) [ 0 ] ;
128
133
await expect (
@@ -133,19 +138,19 @@ describe("Installer", function () {
133
138
installer . connect ( target ) . beforeCall ( "0x" , "0x00000000" , instanceAddress , "0" , "0x" )
134
139
) . to . be . not . revertedWithCustomError ( installer , "NotAnInstance" ) ;
135
140
136
- await distributor . connect ( owner ) . removeDistribution ( cloneDistributionId ) ;
141
+ await distributor . connect ( owner ) . removeDistribution ( distributorsId ) ;
137
142
await expect (
138
143
installer . connect ( target ) . beforeCall ( "0x" , "0x00000000" , instanceAddress , "0" , "0x" )
139
144
) . to . be . revertedWithCustomError ( distributor , "InvalidInstance" ) ;
140
145
} ) ;
141
146
142
147
it ( "Reverts when valid distributions added by distributor and distribution id were removed" , async ( ) => {
143
- await installer . connect ( owner ) . allowDistribution ( distributor . address , cloneDistributionId ) ;
144
- await installer . connect ( owner ) . install ( distributor . address , cloneDistributionId , "0x" ) ;
148
+ await installer . connect ( owner ) . allowDistribution ( distributor . address , distributorsId ) ;
149
+ await installer . connect ( owner ) . install ( distributor . address , distributorsId , "0x" ) ;
145
150
const instanceNum = await installer . connect ( owner ) . getInstancesNum ( ) ;
146
151
let instanceAddress = ( await installer . connect ( target ) . getInstance ( instanceNum ) ) [ 0 ] ;
147
152
148
- await installer . connect ( owner ) . disallowDistribution ( distributor . address , cloneDistributionId ) ;
153
+ await installer . connect ( owner ) . disallowDistribution ( distributor . address , distributorsId ) ;
149
154
150
155
await expect (
151
156
installer . connect ( target ) . beforeCall ( "0x" , "0x00000000" , instanceAddress , "0" , "0x" )
@@ -154,7 +159,7 @@ describe("Installer", function () {
154
159
155
160
it ( "Does reverts on invalid target" , async ( ) => {
156
161
await installer . connect ( owner ) . whitelistDistributor ( distributor . address ) ;
157
- await installer . connect ( owner ) . install ( distributor . address , cloneDistributionId , "0x" ) ;
162
+ await installer . connect ( owner ) . install ( distributor . address , distributorsId , "0x" ) ;
158
163
const instanceNum = await installer . connect ( owner ) . getInstancesNum ( ) ;
159
164
let instanceAddress = ( await installer . connect ( target ) . getInstance ( instanceNum ) ) [ 0 ] ;
160
165
await expect (
0 commit comments