@@ -1076,6 +1076,113 @@ describe('BlacklistTransferManagerWrapper', () => {
1076
1076
} ) ;
1077
1077
} ) ;
1078
1078
1079
+ describe ( 'addMultiInvestorToBlacklistMulti' , ( ) => {
1080
+ test ( 'should call addMultiInvestorToBlacklistMulti' , async ( ) => {
1081
+ const expectedOwnerResult = '0x8888888888888888888888888888888888888888' ;
1082
+ const expectedBlacklistInvestorAddresses = [
1083
+ '0x0123456789012345678901234567890123456789' ,
1084
+ '0x2222222222222222222222222222222222222222' ,
1085
+ '0x9999999999999999999999999999999999999999' ,
1086
+ ] ;
1087
+ const blacklistNames = [ 'Blacklist1' , 'Blacklist4' , 'Blacklist5' ] ;
1088
+ const expectedStartTime = dateToBigNumber ( new Date ( 2030 , 1 ) ) ;
1089
+ const expectedEndTime = dateToBigNumber ( new Date ( 2031 , 1 ) ) ;
1090
+ const expectedRepeatPeriodTime = new BigNumber ( 366 ) ;
1091
+ const expectedGetBlacklistResult = [ expectedStartTime , expectedEndTime , expectedRepeatPeriodTime ] ;
1092
+
1093
+ // Security Token Address expected
1094
+ const expectedSecurityTokenAddress = '0x3333333333333333333333333333333333333333' ;
1095
+ // Setup get Security Token Address
1096
+ const mockedGetSecurityTokenAddressMethod = mock ( MockedCallMethod ) ;
1097
+ when ( mockedContract . securityToken ) . thenReturn ( instance ( mockedGetSecurityTokenAddressMethod ) ) ;
1098
+ when ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . thenResolve ( expectedSecurityTokenAddress ) ;
1099
+ when ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . thenResolve (
1100
+ instance ( mockedSecurityTokenContract ) ,
1101
+ ) ;
1102
+
1103
+ const mockedSecurityTokenOwnerMethod = mock ( MockedCallMethod ) ;
1104
+ when ( mockedSecurityTokenOwnerMethod . callAsync ( ) ) . thenResolve ( expectedOwnerResult ) ;
1105
+ when ( mockedSecurityTokenContract . owner ) . thenReturn ( instance ( mockedSecurityTokenOwnerMethod ) ) ;
1106
+
1107
+ // Mock web3 wrapper owner
1108
+ when ( mockedWrapper . getAvailableAddressesAsync ( ) ) . thenResolve ( [ expectedOwnerResult ] ) ;
1109
+
1110
+ // Mocked method
1111
+ const mockedBlacklistsMethod = mock ( MockedCallMethod ) ;
1112
+ // Stub the method
1113
+ when ( mockedContract . blacklists ) . thenReturn ( instance ( mockedBlacklistsMethod ) ) ;
1114
+ for ( let i = 0 ; i < blacklistNames . length ; i += 1 ) {
1115
+ when ( mockedBlacklistsMethod . callAsync ( objectContaining ( stringToBytes32 ( blacklistNames [ i ] ) ) ) ) . thenResolve (
1116
+ expectedGetBlacklistResult ,
1117
+ ) ;
1118
+ }
1119
+
1120
+ const expectedGetBlacklistNamesToUserResult = stringArrayToBytes32Array ( [ 'Blacklist2' , 'Blacklist3' ] ) ;
1121
+ // Mocked method
1122
+ const mockedGetBlacklistNamesToUserMethod = mock ( MockedCallMethod ) ;
1123
+ // Stub the method
1124
+ when ( mockedContract . getBlacklistNamesToUser ) . thenReturn ( instance ( mockedGetBlacklistNamesToUserMethod ) ) ;
1125
+ // Stub the request
1126
+
1127
+ for ( let i = 0 ; i < expectedBlacklistInvestorAddresses . length ; i += 1 ) {
1128
+ when ( mockedGetBlacklistNamesToUserMethod . callAsync ( expectedBlacklistInvestorAddresses [ i ] ) ) . thenResolve (
1129
+ expectedGetBlacklistNamesToUserResult ,
1130
+ ) ;
1131
+ }
1132
+
1133
+ const mockedParams = {
1134
+ userAddresses : expectedBlacklistInvestorAddresses ,
1135
+ blacklistNames,
1136
+ txData : { } ,
1137
+ safetyFactor : 10 ,
1138
+ } ;
1139
+ const expectedResult = getMockedPolyResponse ( ) ;
1140
+ // Mocked method
1141
+ const mockedMethod = mock ( MockedSendMethod ) ;
1142
+ // Stub the method
1143
+ when ( mockedContract . addMultiInvestorToBlacklistMulti ) . thenReturn ( instance ( mockedMethod ) ) ;
1144
+ // Stub the request
1145
+ when (
1146
+ mockedMethod . sendTransactionAsync (
1147
+ mockedParams . userAddresses ,
1148
+ objectContaining ( stringArrayToBytes32Array ( mockedParams . blacklistNames ) ) ,
1149
+ mockedParams . txData ,
1150
+ mockedParams . safetyFactor ,
1151
+ ) ,
1152
+ ) . thenResolve ( expectedResult ) ;
1153
+
1154
+ // Real call
1155
+ const result = await target . addMultiInvestorToBlacklistMulti ( mockedParams ) ;
1156
+
1157
+ // Result expectation
1158
+ expect ( result ) . toBe ( expectedResult ) ;
1159
+ // Verifications
1160
+ verify ( mockedContract . addMultiInvestorToBlacklistMulti ) . once ( ) ;
1161
+ verify (
1162
+ mockedMethod . sendTransactionAsync (
1163
+ mockedParams . userAddresses ,
1164
+ objectContaining ( stringArrayToBytes32Array ( mockedParams . blacklistNames ) ) ,
1165
+ mockedParams . txData ,
1166
+ mockedParams . safetyFactor ,
1167
+ ) ,
1168
+ ) . once ( ) ;
1169
+ verify ( mockedSecurityTokenOwnerMethod . callAsync ( ) ) . once ( ) ;
1170
+ verify ( mockedSecurityTokenContract . owner ) . once ( ) ;
1171
+ verify ( mockedContract . securityToken ) . once ( ) ;
1172
+ verify ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . once ( ) ;
1173
+ verify ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . once ( ) ;
1174
+ verify ( mockedWrapper . getAvailableAddressesAsync ( ) ) . once ( ) ;
1175
+ verify ( mockedContract . blacklists ) . times ( expectedBlacklistInvestorAddresses . length ) ;
1176
+ for ( let i = 0 ; i < blacklistNames . length ; i += 1 ) {
1177
+ verify ( mockedBlacklistsMethod . callAsync ( objectContaining ( stringToBytes32 ( blacklistNames [ i ] ) ) ) ) . once ( ) ;
1178
+ }
1179
+ verify ( mockedContract . getBlacklistNamesToUser ) . times ( expectedBlacklistInvestorAddresses . length ) ;
1180
+ for ( let i = 0 ; i < expectedBlacklistInvestorAddresses . length ; i += 1 ) {
1181
+ verify ( mockedGetBlacklistNamesToUserMethod . callAsync ( expectedBlacklistInvestorAddresses [ i ] ) ) . once ( ) ;
1182
+ }
1183
+ } ) ;
1184
+ } ) ;
1185
+
1079
1186
describe ( 'getListOfAddresses' , ( ) => {
1080
1187
test . todo ( 'should fail as blacklist name is an empty string' ) ;
1081
1188
0 commit comments