@@ -37,8 +37,10 @@ contract("CountTransferManager", async (accounts) => {
37
37
let I_GeneralPermissionManager ;
38
38
let I_CountTransferManager ;
39
39
let I_CountTransferManager2 ;
40
+ let I_CountTransferManager3 ;
40
41
let I_GeneralTransferManager ;
41
42
let I_GeneralTransferManager2 ;
43
+ let I_GeneralTransferManager3 ;
42
44
let I_ExchangeTransferManager ;
43
45
let I_ModuleRegistry ;
44
46
let I_ModuleRegistryProxy ;
@@ -49,17 +51,21 @@ contract("CountTransferManager", async (accounts) => {
49
51
let I_STFactory ;
50
52
let I_SecurityToken ;
51
53
let I_SecurityToken2 ;
54
+ let I_SecurityToken3 ;
52
55
let I_PolyToken ;
53
56
let I_PolymathRegistry ;
54
57
let I_STRGetter ;
55
58
let I_STGetter ;
59
+ let I_MockCountTransferManagerLogic ;
56
60
let stGetter ;
57
61
let stGetter2 ;
62
+ let stGetter3 ;
58
63
59
64
// SecurityToken Details
60
65
const name = "Team" ;
61
66
const symbol = "sap" ;
62
67
const symbol2 = "sapp" ;
68
+ const symbol3 = "sapp3"
63
69
const tokenDetails = "This is equity type of issuance" ;
64
70
const decimals = 18 ;
65
71
const contact = "[email protected] " ;
@@ -373,6 +379,21 @@ contract("CountTransferManager", async (accounts) => {
373
379
I_GeneralTransferManager2 = await GeneralTransferManager . at ( moduleData ) ;
374
380
} ) ;
375
381
382
+ it ( "deploy another new token & auto attach modules" , async ( ) => {
383
+ //register ticker and deploy token
384
+ await I_PolyToken . approve ( I_STRProxied . address , initRegFee , { from : token_owner } ) ;
385
+ let tx = await I_STRProxied . registerTicker ( token_owner , symbol3 , contact , { from : token_owner } ) ;
386
+
387
+ await I_PolyToken . approve ( I_STRProxied . address , initRegFee , { from : token_owner } ) ;
388
+
389
+ let tx2 = await I_STRProxied . generateNewSecurityToken ( name , symbol3 , tokenDetails , false , token_owner , 0 , { from : token_owner } ) ;
390
+
391
+ I_SecurityToken3 = await SecurityToken . at ( tx2 . logs [ 1 ] . args . _securityTokenAddress ) ;
392
+ stGetter3 = await STGetter . at ( I_SecurityToken3 . address ) ;
393
+ let moduleData = ( await stGetter3 . getModulesByType ( 2 ) ) [ 0 ] ;
394
+ I_GeneralTransferManager3 = await GeneralTransferManager . at ( moduleData ) ;
395
+ } ) ;
396
+
376
397
it ( "add 3 holders to the token" , async ( ) => {
377
398
await I_GeneralTransferManager2 . modifyKYCData (
378
399
account_investor1 ,
@@ -455,8 +476,21 @@ contract("CountTransferManager", async (accounts) => {
455
476
console . log ( "current max holder number is " + ( await I_CountTransferManager2 . maxHolderCount ( { from : token_owner } ) ) ) ;
456
477
} ) ;
457
478
479
+ it ( "Should successfully attach the CountTransferManager with the third security token and set max holder to 2" , async ( ) => {
480
+ const tx = await I_SecurityToken3 . addModule ( I_CountTransferManagerFactory . address , bytesSTO , new BN ( 0 ) , new BN ( 0 ) , false , { from : token_owner } ) ;
481
+ assert . equal ( tx . logs [ 2 ] . args . _types [ 0 ] . toNumber ( ) , transferManagerKey , "CountTransferManager doesn't get deployed" ) ;
482
+ assert . equal (
483
+ web3 . utils . toAscii ( tx . logs [ 2 ] . args . _name ) . replace ( / \u0000 / g, "" ) ,
484
+ "CountTransferManager" ,
485
+ "CountTransferManager module was not added"
486
+ ) ;
487
+ I_CountTransferManager3 = await CountTransferManager . at ( tx . logs [ 2 ] . args . _module ) ;
488
+ await I_CountTransferManager3 . changeHolderCount ( 2 , { from : token_owner } ) ;
489
+ console . log ( "current max holder number is " + ( await I_CountTransferManager3 . maxHolderCount ( { from : token_owner } ) ) ) ;
490
+ } ) ;
491
+
458
492
it ( "Should upgrade the CTM" , async ( ) => {
459
- let I_MockCountTransferManagerLogic = await MockCountTransferManager . new ( "0x0000000000000000000000000000000000000000" , "0x0000000000000000000000000000000000000000" , { from : account_polymath } ) ;
493
+ I_MockCountTransferManagerLogic = await MockCountTransferManager . new ( "0x0000000000000000000000000000000000000000" , "0x0000000000000000000000000000000000000000" , { from : account_polymath } ) ;
460
494
let bytesCM = encodeProxyCall ( [ "uint256" ] , [ 11 ] ) ;
461
495
await catchRevert (
462
496
// Fails as no upgrade available
@@ -482,9 +516,39 @@ contract("CountTransferManager", async (accounts) => {
482
516
let tx = await I_MRProxied . verifyModule ( I_CountTransferManagerFactory . address , { from : account_polymath } ) ;
483
517
await I_SecurityToken2 . upgradeModule ( I_CountTransferManager2 . address , { from : token_owner } ) ;
484
518
let I_MockCountTransferManager = await MockCountTransferManager . at ( I_CountTransferManager2 . address ) ;
519
+ let newValue = await I_MockCountTransferManager . someValue . call ( ) ;
520
+ assert ( newValue . toNumber ( ) , 11 ) ;
485
521
await I_MockCountTransferManager . newFunction ( ) ;
486
522
} ) ;
487
523
524
+ it ( "Should modify the upgrade data and upgrade" , async ( ) => {
525
+ let bytesCM = encodeProxyCall ( [ "uint256" ] , [ 12 ] ) ;
526
+ await catchRevert (
527
+ // Fails due to the same version being used
528
+ I_CountTransferManagerFactory . updateLogicContract ( 1 , "3.0.0" , I_MockCountTransferManagerLogic . address , bytesCM , { from : account_polymath } )
529
+ ) ;
530
+ await catchRevert (
531
+ // Fails due to the wrong contract being used
532
+ I_CountTransferManagerFactory . updateLogicContract ( 1 , "4.0.0" , "0x0000000000000000000000000000000000000000" , bytesCM , { from : account_polymath } )
533
+ ) ;
534
+ await catchRevert (
535
+ // Fails due to the wrong owner being used
536
+ I_CountTransferManagerFactory . updateLogicContract ( 1 , "4.0.0" , "0x0000000000000000000000000000000000000000" , bytesCM , { from : token_owner } )
537
+ ) ;
538
+ await I_CountTransferManagerFactory . updateLogicContract ( 1 , "4.0.0" , I_MockCountTransferManagerLogic . address , bytesCM , { from : account_polymath } ) ;
539
+ await catchRevert (
540
+ // Fails as upgraded module has been unverified
541
+ I_SecurityToken3 . upgradeModule ( I_CountTransferManager3 . address , { from : token_owner } )
542
+ ) ;
543
+ let tx = await I_MRProxied . verifyModule ( I_CountTransferManagerFactory . address , { from : account_polymath } ) ;
544
+ await I_SecurityToken3 . upgradeModule ( I_CountTransferManager3 . address , { from : token_owner } ) ;
545
+ let I_MockCountTransferManager = await MockCountTransferManager . at ( I_CountTransferManager3 . address ) ;
546
+ let newValue = await I_MockCountTransferManager . someValue . call ( ) ;
547
+ assert ( newValue . toNumber ( ) , 12 ) ;
548
+ await I_MockCountTransferManager . newFunction ( ) ;
549
+
550
+ } ) ;
551
+
488
552
it ( "Should upgrade the CTM again" , async ( ) => {
489
553
let I_MockCountTransferManagerLogic = await MockCountTransferManager . new ( "0x0000000000000000000000000000000000000000" , "0x0000000000000000000000000000000000000000" , { from : account_polymath } ) ;
490
554
let bytesCM = encodeProxyCall ( [ "uint256" ] , [ 11 ] ) ;
0 commit comments