@@ -234,11 +234,7 @@ contract('ManualApprovalTransferManager', accounts => {
234234
235235 // Verify that GeneralTransferManager module get added successfully or not
236236 assert . equal ( log . args . _type . toNumber ( ) , 2 ) ;
237- assert . equal (
238- web3 . utils . toAscii ( log . args . _name )
239- . replace ( / \u0000 / g, '' ) ,
240- "GeneralTransferManager"
241- ) ;
237+ assert . equal ( web3 . utils . toUtf8 ( log . args . _name ) , "GeneralTransferManager" ) ;
242238 LogAddModule . stopWatching ( ) ;
243239 } ) ;
244240
@@ -314,12 +310,7 @@ contract('ManualApprovalTransferManager', accounts => {
314310 it ( "Should successfully attach the ManualApprovalTransferManager with the security token" , async ( ) => {
315311 const tx = await I_SecurityToken . addModule ( I_ManualApprovalTransferManagerFactory . address , "" , 0 , 0 , false , { from : token_owner } ) ;
316312 assert . equal ( tx . logs [ 2 ] . args . _type . toNumber ( ) , transferManagerKey , "ManualApprovalTransferManager doesn't get deployed" ) ;
317- assert . equal (
318- web3 . utils . toAscii ( tx . logs [ 2 ] . args . _name )
319- . replace ( / \u0000 / g, '' ) ,
320- "ManualApprovalTransferManager" ,
321- "ManualApprovalTransferManager module was not added"
322- ) ;
313+ assert . equal ( web3 . utils . toUtf8 ( tx . logs [ 2 ] . args . _name ) , "ManualApprovalTransferManager" , "ManualApprovalTransferManager module was not added" ) ;
323314 I_ManualApprovalTransferManager = ManualApprovalTransferManager . at ( tx . logs [ 2 ] . args . _module ) ;
324315 } ) ;
325316
@@ -359,10 +350,78 @@ contract('ManualApprovalTransferManager', accounts => {
359350 ) ;
360351 } ) ;
361352
353+ it ( "Should fail to add a manual approval because invalid _from address" , async ( ) => {
354+ let errorThrown = false ;
355+ try {
356+ await I_ManualApprovalTransferManager . addManualApproval ( "" , account_investor4 , web3 . utils . toWei ( '2' , 'ether' ) , latestTime ( ) + duration . days ( 1 ) , { from : token_owner } ) ;
357+ } catch ( error ) {
358+ console . log ( ` tx revert -> invalid _from address` . grey ) ;
359+ ensureException ( error ) ;
360+ errorThrown = true ;
361+ }
362+ assert . ok ( errorThrown , message ) ;
363+ } ) ;
364+
365+ it ( "Should fail to add a manual approval because invalid _to address" , async ( ) => {
366+ let errorThrown = false ;
367+ try {
368+ await I_ManualApprovalTransferManager . addManualApproval ( account_investor1 , "" , web3 . utils . toWei ( '2' , 'ether' ) , latestTime ( ) + duration . days ( 1 ) , { from : token_owner } ) ;
369+ } catch ( error ) {
370+ console . log ( ` tx revert -> invalid _to address` . grey ) ;
371+ ensureException ( error ) ;
372+ errorThrown = true ;
373+ }
374+ assert . ok ( errorThrown , message ) ;
375+ } ) ;
376+
377+ it ( "Should fail to add a manual approval because invalid expiry time" , async ( ) => {
378+ let errorThrown = false ;
379+ try {
380+ await I_ManualApprovalTransferManager . addManualApproval ( account_investor1 , account_investor4 , web3 . utils . toWei ( '2' , 'ether' ) , 99999 , { from : token_owner } ) ;
381+ } catch ( error ) {
382+ console . log ( ` tx revert -> invalid expiry time` . grey ) ;
383+ ensureException ( error ) ;
384+ errorThrown = true ;
385+ }
386+ assert . ok ( errorThrown , message ) ;
387+ } ) ;
388+
362389 it ( "Add a manual approval for a 4th investor" , async ( ) => {
363390 await I_ManualApprovalTransferManager . addManualApproval ( account_investor1 , account_investor4 , web3 . utils . toWei ( '2' , 'ether' ) , latestTime ( ) + duration . days ( 1 ) , { from : token_owner } ) ;
364391 } ) ;
365392
393+ it ( "Should fail to revoke manual approval because invalid _from address" , async ( ) => {
394+ let errorThrown = false ;
395+ try {
396+ await I_ManualApprovalTransferManager . revokeManualApproval ( "" , account_investor4 , { from : token_owner } ) ;
397+ } catch ( error ) {
398+ console . log ( ` tx revert -> invalid _from address` . grey ) ;
399+ ensureException ( error ) ;
400+ errorThrown = true ;
401+ }
402+ assert . ok ( errorThrown , message ) ;
403+ } ) ;
404+
405+ it ( "Should fail to revoke manual approval because invalid _to address" , async ( ) => {
406+ let errorThrown = false ;
407+ try {
408+ await I_ManualApprovalTransferManager . revokeManualApproval ( account_investor1 , "" , { from : token_owner } ) ;
409+ } catch ( error ) {
410+ console . log ( ` tx revert -> invalid _to address` . grey ) ;
411+ ensureException ( error ) ;
412+ errorThrown = true ;
413+ }
414+ assert . ok ( errorThrown , message ) ;
415+ } ) ;
416+
417+ it ( "Should revoke manual approval" , async ( ) => {
418+ let tx = await I_ManualApprovalTransferManager . revokeManualApproval ( account_investor1 , account_investor4 , { from : token_owner } ) ;
419+ assert . equal ( tx . logs [ 0 ] . args . _from , account_investor1 ) ;
420+ assert . equal ( tx . logs [ 0 ] . args . _to , account_investor4 ) ;
421+ assert . equal ( tx . logs [ 0 ] . args . _addedBy , token_owner ) ;
422+ await I_ManualApprovalTransferManager . addManualApproval ( account_investor1 , account_investor4 , web3 . utils . toWei ( '2' , 'ether' ) , latestTime ( ) + duration . days ( 1 ) , { from : token_owner } ) ;
423+ } ) ;
424+
366425 it ( "Use 50% of manual approval for transfer" , async ( ) => {
367426 await I_SecurityToken . transfer ( account_investor4 , web3 . utils . toWei ( '1' , 'ether' ) , { from : account_investor1 } ) ;
368427
@@ -410,6 +469,42 @@ contract('ManualApprovalTransferManager', accounts => {
410469
411470 } ) ;
412471
472+ it ( "Should fail to add a manual block because invalid _from address" , async ( ) => {
473+ let errorThrown = false ;
474+ try {
475+ await I_ManualApprovalTransferManager . addManualBlocking ( "" , account_investor2 , latestTime ( ) + duration . days ( 1 ) , { from : token_owner } ) ;
476+ } catch ( error ) {
477+ console . log ( ` tx revert -> invalid _from address` . grey ) ;
478+ ensureException ( error ) ;
479+ errorThrown = true ;
480+ }
481+ assert . ok ( errorThrown , message ) ;
482+ } ) ;
483+
484+ it ( "Should fail to add a manual block because invalid _to address" , async ( ) => {
485+ let errorThrown = false ;
486+ try {
487+ await I_ManualApprovalTransferManager . addManualBlocking ( account_investor1 , "" , latestTime ( ) + duration . days ( 1 ) , { from : token_owner } ) ;
488+ } catch ( error ) {
489+ console . log ( ` tx revert -> invalid _to address` . grey ) ;
490+ ensureException ( error ) ;
491+ errorThrown = true ;
492+ }
493+ assert . ok ( errorThrown , message ) ;
494+ } ) ;
495+
496+ it ( "Should fail to add a manual block because invalid expiry time" , async ( ) => {
497+ let errorThrown = false ;
498+ try {
499+ await I_ManualApprovalTransferManager . addManualBlocking ( account_investor1 , account_investor2 , 99999 , { from : token_owner } ) ;
500+ } catch ( error ) {
501+ console . log ( ` tx revert -> invalid expiry time` . grey ) ;
502+ ensureException ( error ) ;
503+ errorThrown = true ;
504+ }
505+ assert . ok ( errorThrown , message ) ;
506+ } ) ;
507+
413508 it ( "Add a manual block for a 2nd investor" , async ( ) => {
414509 await I_ManualApprovalTransferManager . addManualBlocking ( account_investor1 , account_investor2 , latestTime ( ) + duration . days ( 1 ) , { from : token_owner } ) ;
415510 } ) ;
@@ -427,6 +522,30 @@ contract('ManualApprovalTransferManager', accounts => {
427522
428523 } ) ;
429524
525+ it ( "Should fail to revoke manual block because invalid _from address" , async ( ) => {
526+ let errorThrown = false ;
527+ try {
528+ await I_ManualApprovalTransferManager . revokeManualBlocking ( "0x0" , account_investor2 , { from : token_owner } ) ;
529+ } catch ( error ) {
530+ console . log ( ` tx revert -> invalid _from address` . grey ) ;
531+ ensureException ( error ) ;
532+ errorThrown = true ;
533+ }
534+ assert . ok ( errorThrown , message ) ;
535+ } ) ;
536+
537+ it ( "Should fail to revoke manual block because invalid _to address" , async ( ) => {
538+ let errorThrown = false ;
539+ try {
540+ await I_ManualApprovalTransferManager . revokeManualBlocking ( account_investor1 , "0x0" , { from : token_owner } ) ;
541+ } catch ( error ) {
542+ console . log ( ` tx revert -> invalid _to address` . grey ) ;
543+ ensureException ( error ) ;
544+ errorThrown = true ;
545+ }
546+ assert . ok ( errorThrown , message ) ;
547+ } ) ;
548+
430549 it ( "Revoke manual block and check transfer works" , async ( ) => {
431550 await I_ManualApprovalTransferManager . revokeManualBlocking ( account_investor1 , account_investor2 , { from : token_owner } ) ;
432551 await I_SecurityToken . transfer ( account_investor2 , web3 . utils . toWei ( '1' , 'ether' ) , { from : account_investor1 } ) ;
@@ -464,16 +583,16 @@ contract('ManualApprovalTransferManager', accounts => {
464583
465584 const tx = await I_SecurityToken . addModule ( I_CountTransferManagerFactory . address , bytesCountTM , 0 , 0 , false , { from : token_owner } ) ;
466585 assert . equal ( tx . logs [ 2 ] . args . _type . toNumber ( ) , transferManagerKey , "CountTransferManager doesn't get deployed" ) ;
467- assert . equal (
468- web3 . utils . toAscii ( tx . logs [ 2 ] . args . _name )
469- . replace ( / \u0000 / g, '' ) ,
470- "CountTransferManager" ,
471- "CountTransferManager module was not added"
472- ) ;
586+ let name = web3 . utils . toUtf8 ( tx . logs [ 2 ] . args . _name ) ;
587+ assert . equal ( name , "CountTransferManager" , "CountTransferManager module was not added" ) ;
473588 I_CountTransferManager = CountTransferManager . at ( tx . logs [ 2 ] . args . _module ) ;
474589
475590 } ) ;
476591
592+ it ( "Should get the permission list" , async ( ) => {
593+ let perm = await I_ManualApprovalTransferManager . getPermissions . call ( ) ;
594+ assert . equal ( perm . length , 1 ) ;
595+ } ) ;
477596
478597 // it("Check manual approval has a higher priority than an INVALID result from another TM", async() => {
479598 // //Should fail initial transfer
@@ -497,15 +616,19 @@ contract('ManualApprovalTransferManager', accounts => {
497616 it ( "Should get the exact details of the factory" , async ( ) => {
498617 assert . equal ( await I_ManualApprovalTransferManagerFactory . setupCost . call ( ) , 0 ) ;
499618 assert . equal ( await I_ManualApprovalTransferManagerFactory . getType . call ( ) , 2 ) ;
500- assert . equal ( web3 . utils . toAscii ( await I_ManualApprovalTransferManagerFactory . getName . call ( ) )
501- . replace ( / \u0000 / g, '' ) ,
502- "ManualApprovalTransferManager" ,
503- "Wrong Module added" ) ;
619+ let name = web3 . utils . toUtf8 ( await I_ManualApprovalTransferManagerFactory . getName . call ( ) ) ;
620+ assert . equal ( name , "ManualApprovalTransferManager" , "Wrong Module added" ) ;
621+ let desc = await I_ManualApprovalTransferManagerFactory . getDescription . call ( ) ;
622+ assert . equal ( desc , "Manage transfers using single approvals / blocking" , "Wrong Module added" ) ;
623+ let title = await I_ManualApprovalTransferManagerFactory . getTitle . call ( ) ;
624+ assert . equal ( title , "Manual Approval Transfer Manager" , "Wrong Module added" ) ;
625+ let inst = await I_ManualApprovalTransferManagerFactory . getInstructions . call ( ) ;
626+ assert . equal ( inst , "Allows an issuer to set manual approvals or blocks for specific pairs of addresses and amounts. Init function takes no parameters." , "Wrong Module added" ) ;
504627 } ) ;
505628
506629 it ( "Should get the tags of the factory" , async ( ) => {
507630 let tags = await I_ManualApprovalTransferManagerFactory . getTags . call ( ) ;
508- assert . equal ( web3 . utils . toAscii ( tags [ 0 ] ) . replace ( / \u0000 / g , '' ) , "ManualApproval" ) ;
631+ assert . equal ( web3 . utils . toUtf8 ( tags [ 0 ] ) , "ManualApproval" ) ;
509632 } ) ;
510633 } ) ;
511634
0 commit comments