@@ -930,6 +930,129 @@ describe('LockUpTransferManagerWrapper', () => {
930
930
} ) ;
931
931
} ) ;
932
932
933
+ describe ( 'addLockUpByNameMulti' , ( ) => {
934
+ test ( 'should call addLockUpByNameMulti' , async ( ) => {
935
+ const expectedOwnerResult = '0x8888888888888888888888888888888888888888' ;
936
+ const expectedLockUpInvestorAddresses = [
937
+ '0x0123456789012345678901234567890123456789' ,
938
+ '0x2222222222222222222222222222222222222222' ,
939
+ ] ;
940
+ const lockupNames = [ 'Lockup1' , 'Lockup2' ] ;
941
+ const expectedDecimalsResult = new BigNumber ( 18 ) ;
942
+ const expectedLockupAmount = valueToWei ( new BigNumber ( 0 ) , expectedDecimalsResult ) ;
943
+ const expectedStartTime = dateToBigNumber ( new Date ( 2030 , 1 ) ) ;
944
+ const expectedLockUpPeriodSeconds = new BigNumber ( 3600 ) ;
945
+ const expectedReleaseFrequencySeconds = new BigNumber ( 60 ) ;
946
+ const expectedUnlockedAmount = new BigNumber ( 0 ) ;
947
+ const expectedGetLockupResult = [
948
+ expectedLockupAmount ,
949
+ expectedStartTime ,
950
+ expectedLockUpPeriodSeconds ,
951
+ expectedReleaseFrequencySeconds ,
952
+ expectedUnlockedAmount ,
953
+ ] ;
954
+
955
+ // Security Token Address expected
956
+ const expectedSecurityTokenAddress = '0x3333333333333333333333333333333333333333' ;
957
+ // Setup get Security Token Address
958
+ const mockedGetSecurityTokenAddressMethod = mock ( MockedCallMethod ) ;
959
+ when ( mockedContract . securityToken ) . thenReturn ( instance ( mockedGetSecurityTokenAddressMethod ) ) ;
960
+ when ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . thenResolve ( expectedSecurityTokenAddress ) ;
961
+ when ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . thenResolve (
962
+ instance ( mockedSecurityTokenContract ) ,
963
+ ) ;
964
+ const mockedSecurityTokenDecimalsMethod = mock ( MockedCallMethod ) ;
965
+ when ( mockedSecurityTokenDecimalsMethod . callAsync ( ) ) . thenResolve ( expectedDecimalsResult ) ;
966
+ when ( mockedSecurityTokenContract . decimals ) . thenReturn ( instance ( mockedSecurityTokenDecimalsMethod ) ) ;
967
+ const mockedSecurityTokenOwnerMethod = mock ( MockedCallMethod ) ;
968
+ when ( mockedSecurityTokenOwnerMethod . callAsync ( ) ) . thenResolve ( expectedOwnerResult ) ;
969
+ when ( mockedSecurityTokenContract . owner ) . thenReturn ( instance ( mockedSecurityTokenOwnerMethod ) ) ;
970
+
971
+ // Mock web3 wrapper owner
972
+ when ( mockedWrapper . getAvailableAddressesAsync ( ) ) . thenResolve ( [ expectedOwnerResult ] ) ;
973
+
974
+ // Mocked method
975
+ const mockedGetLockupMethod = mock ( MockedCallMethod ) ;
976
+ // Stub the method
977
+ when ( mockedContract . getLockUp ) . thenReturn ( instance ( mockedGetLockupMethod ) ) ;
978
+ // Stub the request
979
+ for ( let i = 0 ; i < lockupNames . length ; i += 1 ) {
980
+ when ( mockedGetLockupMethod . callAsync ( objectContaining ( stringToBytes32 ( lockupNames [ i ] ) ) ) ) . thenResolve (
981
+ expectedGetLockupResult ,
982
+ ) ;
983
+ }
984
+
985
+ const expectedGetLockupsNamesToUserResult = stringArrayToBytes32Array ( [ 'Lockup3' , 'Lockup4' ] ) ;
986
+ const mockedGetLockupsNamesToUserParams = {
987
+ userAddresses : expectedLockUpInvestorAddresses ,
988
+ } ;
989
+ // Mocked method
990
+ const mockedGetLockupsNamesToUserMethod = mock ( MockedCallMethod ) ;
991
+ // Stub the method
992
+ when ( mockedContract . getLockupsNamesToUser ) . thenReturn ( instance ( mockedGetLockupsNamesToUserMethod ) ) ;
993
+ // Stub the request
994
+ for ( let i = 0 ; i < lockupNames . length ; i += 1 ) {
995
+ when (
996
+ mockedGetLockupsNamesToUserMethod . callAsync ( mockedGetLockupsNamesToUserParams . userAddresses [ i ] ) ,
997
+ ) . thenResolve ( expectedGetLockupsNamesToUserResult ) ;
998
+ }
999
+
1000
+ const mockedParams = {
1001
+ lockupNames,
1002
+ userAddresses : expectedLockUpInvestorAddresses ,
1003
+ txData : { } ,
1004
+ safetyFactor : 10 ,
1005
+ } ;
1006
+ const expectedResult = getMockedPolyResponse ( ) ;
1007
+ // Mocked method
1008
+ const mockedMethod = mock ( MockedSendMethod ) ;
1009
+ // Stub the method
1010
+ when ( mockedContract . addLockUpByNameMulti ) . thenReturn ( instance ( mockedMethod ) ) ;
1011
+ // Stub the request
1012
+ when (
1013
+ mockedMethod . sendTransactionAsync (
1014
+ mockedParams . userAddresses ,
1015
+ objectContaining ( stringArrayToBytes32Array ( mockedParams . lockupNames ) ) ,
1016
+ mockedParams . txData ,
1017
+ mockedParams . safetyFactor ,
1018
+ ) ,
1019
+ ) . thenResolve ( expectedResult ) ;
1020
+
1021
+ // Real call
1022
+ const result = await target . addLockUpByNameMulti ( mockedParams ) ;
1023
+
1024
+ // Result expectation
1025
+ expect ( result ) . toBe ( expectedResult ) ;
1026
+ // Verifications
1027
+ verify ( mockedContract . addLockUpByNameMulti ) . once ( ) ;
1028
+ verify (
1029
+ mockedMethod . sendTransactionAsync (
1030
+ mockedParams . userAddresses ,
1031
+ objectContaining ( stringArrayToBytes32Array ( mockedParams . lockupNames ) ) ,
1032
+ mockedParams . txData ,
1033
+ mockedParams . safetyFactor ,
1034
+ ) ,
1035
+ ) . once ( ) ;
1036
+ verify ( mockedSecurityTokenOwnerMethod . callAsync ( ) ) . once ( ) ;
1037
+ verify ( mockedSecurityTokenContract . owner ) . once ( ) ;
1038
+ verify ( mockedContract . securityToken ) . times ( 3 ) ;
1039
+ verify ( mockedSecurityTokenDecimalsMethod . callAsync ( ) ) . twice ( ) ;
1040
+ verify ( mockedSecurityTokenContract . decimals ) . twice ( ) ;
1041
+ verify ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . times ( 3 ) ;
1042
+ verify ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . times ( 3 ) ;
1043
+ verify ( mockedWrapper . getAvailableAddressesAsync ( ) ) . once ( ) ;
1044
+ verify ( mockedContract . getLockUp ) . times ( lockupNames . length ) ;
1045
+ for ( let i = 0 ; i < lockupNames . length ; i += 1 ) {
1046
+ verify ( mockedGetLockupMethod . callAsync ( objectContaining ( stringToBytes32 ( lockupNames [ i ] ) ) ) ) . once ( ) ;
1047
+ }
1048
+ verify ( mockedContract . getLockupsNamesToUser ) . times ( lockupNames . length ) ;
1049
+ // Stub the request
1050
+ for ( let i = 0 ; i < lockupNames . length ; i += 1 ) {
1051
+ verify ( mockedGetLockupsNamesToUserMethod . callAsync ( mockedGetLockupsNamesToUserParams . userAddresses [ i ] ) ) . once ( ) ;
1052
+ }
1053
+ } ) ;
1054
+ } ) ;
1055
+
933
1056
describe ( 'verifyTransfer' , ( ) => {
934
1057
test ( 'should verify Transfer' , async ( ) => {
935
1058
const statusCode = new BigNumber ( 2 ) ;
0 commit comments