@@ -17,7 +17,7 @@ import {
17
17
} from '../../../utils/convert' ;
18
18
import ModuleFactoryWrapper from '../module_factory_wrapper' ;
19
19
import ContractWrapper from '../../contract_wrapper' ;
20
- import { FULL_DECIMALS , ModuleType } from '../../../types' ;
20
+ import { BoundType , FULL_DECIMALS , ModuleType } from '../../../types' ;
21
21
22
22
describe ( 'ModuleFactoryWrapper' , ( ) => {
23
23
let target : ModuleFactoryWrapper ;
@@ -486,11 +486,11 @@ describe('ModuleFactoryWrapper', () => {
486
486
when ( mockedContract . changeTags ) . thenReturn ( instance ( mockedMethod ) ) ;
487
487
// Stub the request
488
488
when (
489
- mockedMethod . sendTransactionAsync (
490
- objectContaining ( stringArrayToBytes32Array ( mockedParams . tags ) ) ,
491
- mockedParams . txData ,
492
- mockedParams . safetyFactor ,
493
- ) ,
489
+ mockedMethod . sendTransactionAsync (
490
+ objectContaining ( stringArrayToBytes32Array ( mockedParams . tags ) ) ,
491
+ mockedParams . txData ,
492
+ mockedParams . safetyFactor ,
493
+ ) ,
494
494
) . thenResolve ( expectedResult ) ;
495
495
496
496
// Owner Address expected
@@ -514,13 +514,82 @@ describe('ModuleFactoryWrapper', () => {
514
514
verify ( mockedOwnerMethod . callAsync ( ) ) . once ( ) ;
515
515
verify ( mockedContract . changeTags ) . once ( ) ;
516
516
verify (
517
- mockedMethod . sendTransactionAsync (
518
- objectContaining ( stringArrayToBytes32Array ( mockedParams . tags ) ) ,
519
- mockedParams . txData ,
520
- mockedParams . safetyFactor ,
521
- ) ,
517
+ mockedMethod . sendTransactionAsync (
518
+ objectContaining ( stringArrayToBytes32Array ( mockedParams . tags ) ) ,
519
+ mockedParams . txData ,
520
+ mockedParams . safetyFactor ,
521
+ ) ,
522
+ ) . once ( ) ;
523
+ verify ( mockedWrapper . getAvailableAddressesAsync ( ) ) . once ( ) ;
524
+ } ) ;
525
+ } ) ;
526
+
527
+ describe ( 'ChangeSTVersionBounds' , ( ) => {
528
+ test . todo ( 'should fail as there is an invalid bound type used' ) ;
529
+ test . todo ( 'should fail as tags array length is not 3' ) ;
530
+ test ( 'should send the transaction to changeSTVersionBounds' , async ( ) => {
531
+ // Mocked parameters
532
+ const mockedParams = {
533
+ boundType : BoundType . LowerBound ,
534
+ newVersion : [ 2 , 3 , 4 ] ,
535
+ txData : { } ,
536
+ safetyFactor : 10 ,
537
+ } ;
538
+ const expectedResult = getMockedPolyResponse ( ) ;
539
+ // Mocked method
540
+ const mockedMethod = mock ( MockedSendMethod ) ;
541
+ // Stub the method
542
+ when ( mockedContract . changeSTVersionBounds ) . thenReturn ( instance ( mockedMethod ) ) ;
543
+ // Stub the request
544
+ when (
545
+ mockedMethod . sendTransactionAsync (
546
+ mockedParams . boundType ,
547
+ mockedParams . newVersion ,
548
+ mockedParams . txData ,
549
+ mockedParams . safetyFactor ,
550
+ ) ,
551
+ ) . thenResolve ( expectedResult ) ;
552
+
553
+ // Owner Address expected
554
+ const expectedOwnerResult = '0x5555555555555555555555555555555555555555' ;
555
+ // Mocked method
556
+ const mockedOwnerMethod = mock ( MockedCallMethod ) ;
557
+ // Stub the method
558
+ when ( mockedContract . owner ) . thenReturn ( instance ( mockedOwnerMethod ) ) ;
559
+ // Stub the request
560
+ when ( mockedOwnerMethod . callAsync ( ) ) . thenResolve ( expectedOwnerResult ) ;
561
+ // Mock web3 wrapper owner
562
+ when ( mockedWrapper . getAvailableAddressesAsync ( ) ) . thenResolve ( [ expectedOwnerResult ] ) ;
563
+
564
+ // Address expected
565
+ const expectedLowerSTVersionBoundsResult = [ new BigNumber ( 1 ) , new BigNumber ( 2 ) , new BigNumber ( 3 ) ] ;
566
+ // Mocked method
567
+ const mockedLowerSTVersionBoundsMethod = mock ( MockedCallMethod ) ;
568
+ // Stub the method
569
+ when ( mockedContract . getLowerSTVersionBounds ) . thenReturn ( instance ( mockedLowerSTVersionBoundsMethod ) ) ;
570
+ // Stub the request
571
+ when ( mockedLowerSTVersionBoundsMethod . callAsync ( ) ) . thenResolve ( expectedLowerSTVersionBoundsResult ) ;
572
+
573
+ // Real call
574
+ const result = await target . changeSTVersionBounds ( mockedParams ) ;
575
+
576
+ // Result expectation
577
+ expect ( result ) . toBe ( expectedResult ) ;
578
+ // Verifications
579
+ verify ( mockedContract . owner ) . once ( ) ;
580
+ verify ( mockedOwnerMethod . callAsync ( ) ) . once ( ) ;
581
+ verify ( mockedContract . changeSTVersionBounds ) . once ( ) ;
582
+ verify (
583
+ mockedMethod . sendTransactionAsync (
584
+ mockedParams . boundType ,
585
+ mockedParams . newVersion ,
586
+ mockedParams . txData ,
587
+ mockedParams . safetyFactor ,
588
+ ) ,
522
589
) . once ( ) ;
523
590
verify ( mockedWrapper . getAvailableAddressesAsync ( ) ) . once ( ) ;
591
+ verify ( mockedContract . getLowerSTVersionBounds ) . once ( ) ;
592
+ verify ( mockedLowerSTVersionBoundsMethod . callAsync ( ) ) . once ( ) ;
524
593
} ) ;
525
594
} ) ;
526
595
@@ -569,7 +638,7 @@ describe('ModuleFactoryWrapper', () => {
569
638
describe ( 'getLowerSTVersionBounds' , ( ) => {
570
639
test ( 'should get LowerSTVersionBounds' , async ( ) => {
571
640
// Address expected
572
- const expectedResult = [ new BigNumber ( 1 ) , new BigNumber ( 2 ) ] ;
641
+ const expectedResult = [ new BigNumber ( 1 ) , new BigNumber ( 2 ) , new BigNumber ( 3 ) ] ;
573
642
// Mocked method
574
643
const mockedMethod = mock ( MockedCallMethod ) ;
575
644
// Stub the method
0 commit comments