@@ -29,7 +29,6 @@ const ContractEditing = artifacts.require("ContractEditing");
2929
3030contract ( "Colony Network Extensions" , ( accounts ) => {
3131 let colonyNetwork ;
32- let editableColonyNetwork ;
3332 let metaColony ;
3433 let colony ;
3534 let token ;
@@ -73,13 +72,6 @@ contract("Colony Network Extensions", (accounts) => {
7372 colonyNetwork = await setupColonyNetwork ( ) ;
7473 ( { metaColony } = await setupMetaColonyWithLockedCLNYToken ( colonyNetwork ) ) ;
7574
76- const colonyNetworkAsER = await EtherRouter . at ( colonyNetwork . address ) ;
77- const colonyNetworkResolverAddress = await colonyNetworkAsER . resolver ( ) ;
78- const colonyNetworkResolver = await Resolver . at ( colonyNetworkResolverAddress ) ;
79- const contractEditing = await ContractEditing . new ( ) ;
80- await colonyNetworkResolver . register ( "setStorageSlot(uint256,bytes32)" , contractEditing . address ) ;
81- editableColonyNetwork = await ContractEditing . at ( colonyNetwork . address ) ;
82-
8375 ( { colony, token } = await setupRandomColony ( colonyNetwork ) ) ;
8476 await colony . addDomain ( 1 , UINT256_MAX , 1 ) ; // Domain 2
8577
@@ -154,28 +146,67 @@ contract("Colony Network Extensions", (accounts) => {
154146 await metaColony . addExtensionToNetwork ( TEST_EXTENSION , testExtension2Resolver . address ) ;
155147 } ) ;
156148
157- it ( "allows a root user to install an extension with any version " , async ( ) => {
158- const tx = await colony . installExtension ( TEST_EXTENSION , 2 , { from : ROOT } ) ;
149+ it ( "allows a root user to install an extension" , async ( ) => {
150+ const tx = await colony . installExtension ( TEST_EXTENSION , 1 , { from : ROOT } ) ;
159151
160152 const extensionAddress = getExtensionAddressFromTx ( tx ) ;
161- const extension = await TestExtension2 . at ( extensionAddress ) ;
153+ const extension = await TestExtension1 . at ( extensionAddress ) ;
162154 const owner = await extension . owner ( ) ;
163155 expect ( owner ) . to . equal ( colonyNetwork . address ) ;
164156
165157 const identifier = await extension . identifier ( ) ;
166158 const version = await extension . version ( ) ;
167159 const colonyAddress = await extension . getColony ( ) ;
168160 expect ( identifier ) . to . equal ( TEST_EXTENSION ) ;
169- expect ( version ) . to . eq . BN ( 2 ) ;
161+ expect ( version ) . to . eq . BN ( 1 ) ;
170162 expect ( colonyAddress ) . to . equal ( colony . address ) ;
171163
172164 // Only colonyNetwork can install the extension
173165 await checkErrorRevert ( extension . install ( colony . address ) , "ds-auth-unauthorized" ) ;
174166 } ) ;
175167
168+ it ( "allows a root user to install an extension with any version" , async ( ) => {
169+ const tx = await colony . installExtension ( TEST_EXTENSION , 2 , { from : ROOT } ) ;
170+
171+ const extensionAddress = getExtensionAddressFromTx ( tx ) ;
172+ const extension = await TestExtension2 . at ( extensionAddress ) ;
173+
174+ const identifier = await extension . identifier ( ) ;
175+ const version = await extension . version ( ) ;
176+ expect ( identifier ) . to . equal ( TEST_EXTENSION ) ;
177+ expect ( version ) . to . eq . BN ( 2 ) ;
178+ } ) ;
179+
176180 it ( "does not allow an extension to be installed with a nonexistent resolver" , async ( ) => {
177181 await checkErrorRevert ( colony . installExtension ( TEST_EXTENSION , 0 , { from : ROOT } ) , "colony-network-extension-bad-version" ) ;
178182 } ) ;
183+
184+ it ( "allows colonies to migrate to multiExtension bookkeeping" , async ( ) => {
185+ const colonyNetworkAsER = await EtherRouter . at ( colonyNetwork . address ) ;
186+ const colonyNetworkResolverAddress = await colonyNetworkAsER . resolver ( ) ;
187+ const colonyNetworkResolver = await Resolver . at ( colonyNetworkResolverAddress ) ;
188+ const contractEditing = await ContractEditing . new ( ) ;
189+ await colonyNetworkResolver . register ( "setStorageSlot(uint256,bytes32)" , contractEditing . address ) ;
190+ const editableColonyNetwork = await ContractEditing . at ( colonyNetwork . address ) ;
191+
192+ const extension = await TestExtension1 . new ( ) ;
193+ await extension . install ( colony . address ) ;
194+
195+ let colonyAddress ;
196+
197+ colonyAddress = await colonyNetwork . getExtensionMultiInstallation ( extension . address ) ;
198+ expect ( colonyAddress ) . to . equal ( ethers . constants . AddressZero ) ;
199+
200+ // Set up `installations` mapping in the old style
201+ const slot = soliditySha3 ( `0x000000000000000000000000${ colony . address . slice ( 2 ) } ` , soliditySha3 ( TEST_EXTENSION , 39 ) ) ;
202+ const value = `0x000000000000000000000000${ extension . address . slice ( 2 ) } ` ;
203+ await editableColonyNetwork . setStorageSlot ( slot , value ) ;
204+
205+ await colonyNetwork . migrateToMultiExtension ( TEST_EXTENSION , colony . address ) ;
206+
207+ colonyAddress = await colonyNetwork . getExtensionMultiInstallation ( extension . address ) ;
208+ expect ( colonyAddress ) . to . equal ( colony . address ) ;
209+ } ) ;
179210 } ) ;
180211
181212 describe ( "upgrading extensions" , ( ) => {
@@ -200,26 +231,6 @@ contract("Colony Network Extensions", (accounts) => {
200231 expect ( version ) . to . eq . BN ( 2 ) ;
201232 } ) ;
202233
203- it ( "allows root users to upgrade an extension, with the deprecated interface" , async ( ) => {
204- const tx = await colony . installExtension ( TEST_EXTENSION , 1 , { from : ROOT } ) ;
205-
206- const extensionAddress = getExtensionAddressFromTx ( tx ) ;
207- let extension = await ColonyExtension . at ( extensionAddress ) ;
208- let version = await extension . version ( ) ;
209- expect ( version ) . to . eq . BN ( 1 ) ;
210-
211- // Set up `installations` mapping in the old style
212- const slot = soliditySha3 ( `0x000000000000000000000000${ colony . address . slice ( 2 ) } ` , soliditySha3 ( TEST_EXTENSION , 39 ) ) ;
213- const value = `0x000000000000000000000000${ extensionAddress . slice ( 2 ) } ` ;
214- await editableColonyNetwork . setStorageSlot ( slot , value ) ;
215-
216- await colony . methods [ "upgradeExtension(bytes32,uint256)" ] ( TEST_EXTENSION , 2 , { from : ROOT } ) ;
217-
218- extension = await ColonyExtension . at ( extensionAddress ) ;
219- version = await extension . version ( ) ;
220- expect ( version ) . to . eq . BN ( 2 ) ;
221- } ) ;
222-
223234 it ( "does not allow non-root users to upgrade an extension" , async ( ) => {
224235 const tx = await colony . installExtension ( TEST_EXTENSION , 1 , { from : ROOT } ) ;
225236
@@ -279,28 +290,6 @@ contract("Colony Network Extensions", (accounts) => {
279290 await extension . foo ( ) ;
280291 } ) ;
281292
282- it ( "allows root users to deprecate and undeprecate an extension, with the deprecated interface" , async ( ) => {
283- const tx = await colony . installExtension ( TEST_EXTENSION , 1 , { from : ROOT } ) ;
284-
285- const extensionAddress = getExtensionAddressFromTx ( tx ) ;
286- const extension = await TestExtension1 . at ( extensionAddress ) ;
287-
288- // Set up `installations` mapping in the old style
289- const slot = soliditySha3 ( `0x000000000000000000000000${ colony . address . slice ( 2 ) } ` , soliditySha3 ( TEST_EXTENSION , 39 ) ) ;
290- const value = `0x000000000000000000000000${ extensionAddress . slice ( 2 ) } ` ;
291- await editableColonyNetwork . setStorageSlot ( slot , value ) ;
292-
293- await extension . foo ( ) ;
294-
295- await colony . methods [ "deprecateExtension(bytes32,bool)" ] ( TEST_EXTENSION , true , { from : ROOT } ) ;
296-
297- await checkErrorRevert ( extension . foo ( ) , "colony-extension-deprecated" ) ;
298-
299- await colony . methods [ "deprecateExtension(bytes32,bool)" ] ( TEST_EXTENSION , false , { from : ROOT } ) ;
300-
301- await extension . foo ( ) ;
302- } ) ;
303-
304293 it ( "does not allow non-root users to deprecate an extension" , async ( ) => {
305294 const tx = await colony . installExtension ( TEST_EXTENSION , 1 , { from : ROOT } ) ;
306295
@@ -330,27 +319,6 @@ contract("Colony Network Extensions", (accounts) => {
330319 expect ( new BN ( colonyBalance ) ) . to . eq . BN ( 100 ) ;
331320 } ) ;
332321
333- it ( "allows root users to uninstall an extension and send ether to the beneficiary, with the deprecated interface" , async ( ) => {
334- const tx = await colony . installExtension ( TEST_EXTENSION , 1 , { from : ROOT } ) ;
335-
336- const extensionAddress = getExtensionAddressFromTx ( tx ) ;
337- const extension = await TestExtension1 . at ( extensionAddress ) ;
338- await extension . send ( 100 ) ;
339-
340- // Set up `installations` mapping in the old style
341- const slot = soliditySha3 ( `0x000000000000000000000000${ colony . address . slice ( 2 ) } ` , soliditySha3 ( TEST_EXTENSION , 39 ) ) ;
342- const value = `0x000000000000000000000000${ extensionAddress . slice ( 2 ) } ` ;
343- await editableColonyNetwork . setStorageSlot ( slot , value ) ;
344-
345- // Only colonyNetwork can uninstall
346- await checkErrorRevert ( extension . uninstall ( ) , "ds-auth-unauthorized" ) ;
347-
348- await colony . methods [ "uninstallExtension(bytes32)" ] ( TEST_EXTENSION , { from : ROOT } ) ;
349-
350- const colonyBalance = await web3GetBalance ( colony . address ) ;
351- expect ( new BN ( colonyBalance ) ) . to . eq . BN ( 100 ) ;
352- } ) ;
353-
354322 it ( "does not allow non-root users to uninstall an extension" , async ( ) => {
355323 await checkErrorRevert ( colony . methods [ "uninstallExtension(address)" ] ( ethers . constants . AddressZero , { from : USER } ) , "ds-auth-unauthorized" ) ;
356324 } ) ;
0 commit comments