@@ -55,7 +55,6 @@ contract('SecurityTokenRegistry', accounts => {
5555 let I_STVersion ;
5656 let I_SecurityToken ;
5757 let I_DummySTO ;
58- let I_PolyToken ;
5958 let I_PolyFaucet ;
6059 let I_STVersion002 ;
6160 let I_SecurityToken002 ;
@@ -113,12 +112,12 @@ contract('SecurityTokenRegistry', accounts => {
113112
114113 // ----------- POLYMATH NETWORK Configuration ------------
115114
116- // Step 0: Deploy the Polytoken Contract
117- I_PolyToken = await PolyToken . new ( ) ;
115+ // Step 0: Deploy the token Faucet
116+ I_PolyFaucet = await PolyTokenFaucet . new ( ) ;
118117
119118 // STEP 1: Deploy the ModuleRegistry
120119
121- I_ModuleRegistry = await ModuleRegistry . new ( { from :account_polymath } ) ;
120+ I_ModuleRegistry = await ModuleRegistry . new ( { from : account_polymath } ) ;
122121
123122 assert . notEqual (
124123 I_ModuleRegistry . address . valueOf ( ) ,
@@ -128,7 +127,7 @@ contract('SecurityTokenRegistry', accounts => {
128127
129128 // STEP 2: Deploy the GeneralTransferManagerFactory
130129
131- I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory . new ( I_PolyToken . address , { from :account_polymath } ) ;
130+ I_GeneralTransferManagerFactory = await GeneralTransferManagerFactory . new ( I_PolyFaucet . address , { from : account_polymath } ) ;
132131
133132 assert . notEqual (
134133 I_GeneralTransferManagerFactory . address . valueOf ( ) ,
@@ -138,25 +137,16 @@ contract('SecurityTokenRegistry', accounts => {
138137
139138 // STEP 3: Deploy the GeneralDelegateManagerFactory
140139
141- I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory . new ( I_PolyToken . address , { from :account_polymath } ) ;
140+ I_GeneralPermissionManagerFactory = await GeneralPermissionManagerFactory . new ( I_PolyFaucet . address , { from : account_polymath } ) ;
142141
143142 assert . notEqual (
144143 I_GeneralPermissionManagerFactory . address . valueOf ( ) ,
145144 "0x0000000000000000000000000000000000000000" ,
146145 "GeneralDelegateManagerFactory contract was not deployed"
147146 ) ;
148147
149- // STEP 4: Deploy the CappedSTOFactory
150148
151- I_TestSTOFactory = await TestSTOFactory . new ( I_PolyToken . address , { from : token_owner } ) ;
152-
153- assert . notEqual (
154- I_TestSTOFactory . address . valueOf ( ) ,
155- "0x0000000000000000000000000000000000000000" ,
156- "TestSTOFactory contract was not deployed"
157- ) ;
158-
159- // STEP 5: Register the Modules with the ModuleRegistry contract
149+ // STEP 4: Register the Modules with the ModuleRegistry contract
160150
161151 // (A) : Register the GeneralTransferManagerFactory
162152 await I_ModuleRegistry . registerModule ( I_GeneralTransferManagerFactory . address , { from : account_polymath } ) ;
@@ -166,10 +156,7 @@ contract('SecurityTokenRegistry', accounts => {
166156 await I_ModuleRegistry . registerModule ( I_GeneralPermissionManagerFactory . address , { from : account_polymath } ) ;
167157 await I_ModuleRegistry . verifyModule ( I_GeneralPermissionManagerFactory . address , true , { from : account_polymath } ) ;
168158
169- // (C) : Register the STOFactory
170- await I_ModuleRegistry . registerModule ( I_TestSTOFactory . address , { from : token_owner } ) ;
171-
172- // Step 6: Deploy the TickerRegistry
159+ // Step 5: Deploy the TickerRegistry
173160
174161 I_TickerRegistry = await TickerRegistry . new ( { from : account_polymath } ) ;
175162
@@ -179,7 +166,7 @@ contract('SecurityTokenRegistry', accounts => {
179166 "TickerRegistry contract was not deployed" ,
180167 ) ;
181168
182- // Step 7 : Deploy the STversionProxy contract
169+ // Step 6 : Deploy the STversionProxy contract
183170
184171 I_STVersion = await STVersion . new ( I_GeneralTransferManagerFactory . address , I_GeneralPermissionManagerFactory . address , { from : account_polymath } ) ;
185172
@@ -189,8 +176,18 @@ contract('SecurityTokenRegistry', accounts => {
189176 "STVersion contract was not deployed" ,
190177 ) ;
191178
192- // Step 8: Deploy the token Faucet
193- I_PolyFaucet = await PolyTokenFaucet . new ( ) ;
179+ // STEP 8: Deploy the CappedSTOFactory
180+
181+ I_TestSTOFactory = await TestSTOFactory . new ( I_PolyFaucet . address , { from : token_owner } ) ;
182+
183+ assert . notEqual (
184+ I_TestSTOFactory . address . valueOf ( ) ,
185+ "0x0000000000000000000000000000000000000000" ,
186+ "TestSTOFactory contract was not deployed"
187+ ) ;
188+
189+ // (C) : Register the STOFactory
190+ await I_ModuleRegistry . registerModule ( I_TestSTOFactory . address , { from : token_owner } ) ;
194191
195192 // Step 9: Deploy the SecurityTokenRegistry
196193
@@ -374,7 +371,7 @@ contract('SecurityTokenRegistry', accounts => {
374371 ) ;
375372 } ) ;
376373
377- it ( "Should successfully attach the STO factory with the security token" , async ( ) => {
374+ it ( "Should failed in attaching the STO factory with the security token -- because securityToken doesn't have sufficient balance " , async ( ) => {
378375 let bytesSTO = web3 . eth . abi . encodeFunctionCall (
379376 functionSignature ,
380377 [
@@ -384,26 +381,60 @@ contract('SecurityTokenRegistry', accounts => {
384381 someString ,
385382 ] ) ;
386383
384+ let errorThrown = false ;
385+
386+ try {
387+ const tx = await I_SecurityToken . addModule (
388+ I_TestSTOFactory . address ,
389+ bytesSTO ,
390+ ( 1000 * Math . pow ( 10 , 18 ) ) ,
391+ ( 1000 * Math . pow ( 10 , 18 ) ) ,
392+ true ,
393+ {
394+ from : token_owner ,
395+ gas : 2500000
396+ } ) ;
397+ } catch ( error ) {
398+ console . log ( `Tx. get failed. Becuase securityToken doesn't have sufficient POLY to pay` ) ;
399+ errorThrown = true ;
400+ }
401+ assert . ok ( errorThrown , message ) ;
402+ } ) ;
403+
404+ it ( "Should successfully attach the STO factory with the security token" , async ( ) => {
405+ let bytesSTO = web3 . eth . abi . encodeFunctionCall (
406+ functionSignature ,
407+ [
408+ ( latestTime ( ) + duration . seconds ( 500 ) ) ,
409+ ( latestTime ( ) + duration . days ( 30 ) ) ,
410+ cap ,
411+ someString ,
412+ ] ) ;
413+
414+ await I_PolyFaucet . getTokens ( ( 1000 * Math . pow ( 10 , 18 ) ) , I_SecurityToken . address ) ;
415+
387416 const tx = await I_SecurityToken . addModule (
388417 I_TestSTOFactory . address ,
389418 bytesSTO ,
390419 ( 1000 * Math . pow ( 10 , 18 ) ) ,
391420 ( 1000 * Math . pow ( 10 , 18 ) ) ,
392- false ,
421+ true ,
393422 {
394423 from : token_owner ,
395424 gas : 2500000
396425 } ) ;
397-
398- assert . equal ( tx . logs [ 2 ] . args . _type , stoKey , "TestSTO doesn't get deployed" ) ;
426+
427+ assert . equal ( tx . logs [ 3 ] . args . _type , stoKey , "TestSTO doesn't get deployed" ) ;
399428 assert . equal (
400- web3 . utils . toAscii ( tx . logs [ 2 ] . args . _name )
429+ web3 . utils . toAscii ( tx . logs [ 3 ] . args . _name )
401430 . replace ( / \u0000 / g, '' ) ,
402431 "TestSTO" ,
403432 "TestSTOFactory module was not added"
404433 ) ;
405- I_DummySTO = DummySTO . at ( tx . logs [ 2 ] . args . _module ) ;
434+
435+ I_DummySTO = DummySTO . at ( tx . logs [ 3 ] . args . _module ) ;
406436 } ) ;
437+
407438 } ) ;
408439
409440
0 commit comments