@@ -5,7 +5,7 @@ const Reputation = artifacts.require("./Reputation.sol");
55const Avatar = artifacts . require ( "./Avatar.sol" ) ;
66const Controller = artifacts . require ( "./Controller.sol" ) ;
77const SchemeMock = artifacts . require ( './test/SchemeMock.sol' ) ;
8-
8+ const Wallet = artifacts . require ( './test/Wallet.sol' ) ;
99
1010var avatar ;
1111var daoToken ;
@@ -73,38 +73,45 @@ contract('DaoFactory', function(accounts) {
7373 assert . equal ( controllerReputationAddress , reputationAddress ) ;
7474 } ) ;
7575
76- it ( "setSchemes" , async function ( ) {
76+ it ( "setSchemes" , async function ( ) {
7777 var amountToMint = 10 ;
7878 await setup ( accounts , amountToMint , amountToMint ) ;
7979 var schemeMockData1 = await new web3 . eth . Contract ( registration . schemeMock . abi )
8080 . methods
8181 . initialize ( avatar . address , 1 )
8282 . encodeABI ( ) ;
83+
8384 var schemeMockData2 = await new web3 . eth . Contract ( registration . schemeMock . abi )
8485 . methods
8586 . initialize ( avatar . address , 2 )
8687 . encodeABI ( ) ;
87- var bytesConcate = await registration . daoFactory . bytesConcat ( schemeMockData1 , schemeMockData2 ) ;
88+ var walletData = await new web3 . eth . Contract ( registration . wallet . abi )
89+ . methods
90+ . initialize ( avatar . address )
91+ . encodeABI ( ) ;
8892
8993 var tx = await registration . daoFactory . setSchemes (
9094 avatar . address ,
91- [ web3 . utils . fromAscii ( "SchemeMock" ) , web3 . utils . fromAscii ( "SchemeMock" ) ] ,
92- bytesConcate [ 0 ] ,
93- [ bytesConcate [ 1 ] , bytesConcate [ 2 ] ] ,
94- [ "0x0000000F" , "0x0000000F" ] ,
95+ [ web3 . utils . fromAscii ( "Wallet" ) ,
96+ web3 . utils . fromAscii ( "SchemeMock" ) ,
97+ web3 . utils . fromAscii ( "SchemeMock" ) ] ,
98+ helpers . concatBytes ( helpers . concatBytes ( walletData , schemeMockData1 ) , schemeMockData2 ) ,
99+ [ helpers . getBytesLength ( walletData ) , helpers . getBytesLength ( schemeMockData1 ) , helpers . getBytesLength ( schemeMockData2 ) ] ,
100+ [ "0x0000000F" , "0x0000000F" , "0x0000000F" ] ,
95101 "metaData" ) ;
96- assert . equal ( tx . logs . length , 5 ) ;
97- assert . equal ( tx . logs [ 4 ] . event , "InitialSchemesSet" ) ;
98- assert . equal ( tx . logs [ 4 ] . args . _avatar , avatar . address ) ;
99-
102+ assert . equal ( tx . logs . length , 7 ) ;
103+ assert . equal ( tx . logs [ 6 ] . event , "InitialSchemesSet" ) ;
104+ assert . equal ( tx . logs [ 6 ] . args . _avatar , avatar . address ) ;
100105 assert . equal ( tx . logs [ 1 ] . event , "SchemeInstance" ) ;
101- var scheme1Instance = new SchemeMock ( tx . logs [ 1 ] . args . _scheme ) ;
102- var scheme2Instance = new SchemeMock ( tx . logs [ 3 ] . args . _scheme ) ;
106+ var walletInstance = new Wallet ( tx . logs [ 1 ] . args . _scheme ) ;
107+ var scheme1Instance = new SchemeMock ( tx . logs [ 3 ] . args . _scheme ) ;
108+ var scheme2Instance = new SchemeMock ( tx . logs [ 5 ] . args . _scheme ) ;
103109 assert . equal ( await scheme1Instance . testData ( { from :accounts [ 1 ] } ) , 1 ) ;
104110 assert . equal ( await scheme2Instance . testData ( { from :accounts [ 1 ] } ) , 2 ) ;
105-
111+ assert . equal ( await walletInstance . owner ( { from : accounts [ 1 ] } ) , avatar . address ) ;
106112 } ) ;
107113
114+
108115 it ( "setSchemes from account that does not hold the lock" , async function ( ) {
109116 var amountToMint = 10 ;
110117 await setup ( accounts , amountToMint , amountToMint ) ;
@@ -116,14 +123,13 @@ contract('DaoFactory', function(accounts) {
116123 . methods
117124 . initialize ( avatar . address , 2 )
118125 . encodeABI ( ) ;
119- var bytesConcate = await registration . daoFactory . bytesConcat ( schemeMockData1 , schemeMockData2 ) ;
120126
121127 try {
122128 await registration . daoFactory . setSchemes (
123129 avatar . address ,
124130 [ web3 . utils . fromAscii ( "SchemeMock" ) , web3 . utils . fromAscii ( "SchemeMock" ) ] ,
125- bytesConcate [ 0 ] ,
126- [ bytesConcate [ 1 ] , bytesConcate [ 2 ] ] ,
131+ helpers . concatBytes ( schemeMockData1 , schemeMockData2 ) ,
132+ [ helpers . getBytesLength ( schemeMockData1 ) , helpers . getBytesLength ( schemeMockData2 ) ] ,
127133 [ "0x0000000F" , "0x0000000F" ] ,
128134 "metaData" , { from :accounts [ 1 ] } ) ;
129135 assert ( false , "should fail because accounts[1] does not hold the lock" ) ;
@@ -141,13 +147,12 @@ contract('DaoFactory', function(accounts) {
141147 . methods
142148 . initialize ( avatar . address , 1 )
143149 . encodeABI ( ) ;
144- var bytesConcate = await registration . daoFactory . bytesConcat ( schemeMockData1 , "0x" ) ;
145150
146151 var tx = await registration . daoFactory . setSchemes (
147152 avatar . address ,
148153 [ web3 . utils . fromAscii ( "SchemeMock" ) ] ,
149- bytesConcate [ 0 ] ,
150- [ bytesConcate [ 1 ] ] ,
154+ schemeMockData1 ,
155+ [ helpers . getBytesLength ( schemeMockData1 ) ] ,
151156 [ "0x0000000F" ] ,
152157 "metaData" ) ;
153158 controllerAddress = await avatar . owner ( { from :accounts [ 1 ] } ) ;
@@ -169,13 +174,12 @@ contract('DaoFactory', function(accounts) {
169174 . methods
170175 . initialize ( avatar . address , 1 )
171176 . encodeABI ( ) ;
172- var bytesConcate = await registration . daoFactory . bytesConcat ( schemeMockData1 , "0x" ) ;
173177
174178 await registration . daoFactory . setSchemes (
175179 avatar . address ,
176180 [ web3 . utils . fromAscii ( "SchemeMock" ) ] ,
177- bytesConcate [ 0 ] ,
178- [ bytesConcate [ 1 ] ] ,
181+ schemeMockData1 ,
182+ [ helpers . getBytesLength ( schemeMockData1 ) ] ,
179183 [ "0x0000000F" ] ,
180184 "metaData" ) ;
181185 isSchemeRegistered = await controller . isSchemeRegistered ( registration . daoFactory . address , { from :accounts [ 1 ] } ) ;
@@ -189,21 +193,20 @@ contract('DaoFactory', function(accounts) {
189193 . methods
190194 . initialize ( avatar . address , 1 )
191195 . encodeABI ( ) ;
192- var bytesConcate = await registration . daoFactory . bytesConcat ( schemeMockData1 , "0x" ) ;
193196
194197 await registration . daoFactory . setSchemes (
195198 avatar . address ,
196199 [ web3 . utils . fromAscii ( "SchemeMock" ) ] ,
197- bytesConcate [ 0 ] ,
198- [ bytesConcate [ 1 ] ] ,
200+ schemeMockData1 ,
201+ [ helpers . getBytesLength ( schemeMockData1 ) ] ,
199202 [ "0x0000000F" ] ,
200203 "metaData" ) ;
201204 try {
202205 await registration . daoFactory . setSchemes (
203206 avatar . address ,
204207 [ web3 . utils . fromAscii ( "SchemeMock" ) ] ,
205- bytesConcate [ 0 ] ,
206- [ bytesConcate [ 1 ] ] ,
208+ schemeMockData1 ,
209+ [ helpers . getBytesLength ( schemeMockData1 ) ] ,
207210 [ "0x0000000F" ] ,
208211 "metaData" ) ;
209212 assert ( false , "should fail because lock for account[0] suppose to be deleted by the first call" ) ;
@@ -271,13 +274,12 @@ contract('DaoFactory', function(accounts) {
271274 . methods
272275 . initialize ( avatar . address , 1 )
273276 . encodeABI ( ) ;
274- var bytesConcate = await registration . daoFactory . bytesConcat ( schemeMockData1 , "0x" ) ;
275277
276278 var tx = await registration . daoFactory . setSchemes (
277279 avatar . address ,
278280 [ web3 . utils . fromAscii ( "SchemeMock" ) ] ,
279- bytesConcate [ 0 ] ,
280- [ bytesConcate [ 1 ] ] ,
281+ schemeMockData1 ,
282+ [ helpers . getBytesLength ( schemeMockData1 ) ] ,
281283 [ "0x0000000F" ] ,
282284 "metaData" ) ;
283285 assert . equal ( tx . logs . length , 3 ) ;
0 commit comments