@@ -814,6 +814,122 @@ describe('LockUpTransferManagerWrapper', () => {
814
814
} ) ;
815
815
} ) ;
816
816
817
+ describe ( 'addLockUpByName' , ( ) => {
818
+ test ( 'should call addLockUpByName' , async ( ) => {
819
+ const expectedOwnerResult = '0x8888888888888888888888888888888888888888' ;
820
+ const expectedLockUpInvestorAddress = '0x4444444444444444444444444444444444444444' ;
821
+ const lockupName = 'Lockup3' ;
822
+ const expectedDecimalsResult = new BigNumber ( 18 ) ;
823
+ const expectedLockupAmount = valueToWei ( new BigNumber ( 10 ) , expectedDecimalsResult ) ;
824
+ const expectedStartTime = dateToBigNumber ( new Date ( 2030 , 1 ) ) ;
825
+ const expectedLockUpPeriodSeconds = new BigNumber ( 3600 ) ;
826
+ const expectedReleaseFrequencySeconds = new BigNumber ( 60 ) ;
827
+ const expectedUnlockedAmount = new BigNumber ( 0 ) ;
828
+ const expectedGetLockupResult = [
829
+ expectedLockupAmount ,
830
+ expectedStartTime ,
831
+ expectedLockUpPeriodSeconds ,
832
+ expectedReleaseFrequencySeconds ,
833
+ expectedUnlockedAmount ,
834
+ ] ;
835
+ const mockedGetLockupParams = {
836
+ lockupName,
837
+ } ;
838
+
839
+ // Security Token Address expected
840
+ const expectedSecurityTokenAddress = '0x3333333333333333333333333333333333333333' ;
841
+ // Setup get Security Token Address
842
+ const mockedGetSecurityTokenAddressMethod = mock ( MockedCallMethod ) ;
843
+ when ( mockedContract . securityToken ) . thenReturn ( instance ( mockedGetSecurityTokenAddressMethod ) ) ;
844
+ when ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . thenResolve ( expectedSecurityTokenAddress ) ;
845
+ when ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . thenResolve (
846
+ instance ( mockedSecurityTokenContract ) ,
847
+ ) ;
848
+ const mockedSecurityTokenDecimalsMethod = mock ( MockedCallMethod ) ;
849
+ when ( mockedSecurityTokenDecimalsMethod . callAsync ( ) ) . thenResolve ( expectedDecimalsResult ) ;
850
+ when ( mockedSecurityTokenContract . decimals ) . thenReturn ( instance ( mockedSecurityTokenDecimalsMethod ) ) ;
851
+ const mockedSecurityTokenOwnerMethod = mock ( MockedCallMethod ) ;
852
+ when ( mockedSecurityTokenOwnerMethod . callAsync ( ) ) . thenResolve ( expectedOwnerResult ) ;
853
+ when ( mockedSecurityTokenContract . owner ) . thenReturn ( instance ( mockedSecurityTokenOwnerMethod ) ) ;
854
+
855
+ // Mock web3 wrapper owner
856
+ when ( mockedWrapper . getAvailableAddressesAsync ( ) ) . thenResolve ( [ expectedOwnerResult ] ) ;
857
+
858
+ // Mocked method
859
+ const mockedGetLockupMethod = mock ( MockedCallMethod ) ;
860
+ // Stub the method
861
+ when ( mockedContract . getLockUp ) . thenReturn ( instance ( mockedGetLockupMethod ) ) ;
862
+ // Stub the request
863
+ when (
864
+ mockedGetLockupMethod . callAsync ( objectContaining ( stringToBytes32 ( mockedGetLockupParams . lockupName ) ) ) ,
865
+ ) . thenResolve ( expectedGetLockupResult ) ;
866
+
867
+ const expectedGetLockupsNamesToUserResult = stringArrayToBytes32Array ( [ 'Lockup1' , 'Lockup2' ] ) ;
868
+ const mockedGetLockupsNamesToUserParams = {
869
+ user : expectedLockUpInvestorAddress ,
870
+ } ;
871
+ // Mocked method
872
+ const mockedGetLockupsNamesToUserMethod = mock ( MockedCallMethod ) ;
873
+ // Stub the method
874
+ when ( mockedContract . getLockupsNamesToUser ) . thenReturn ( instance ( mockedGetLockupsNamesToUserMethod ) ) ;
875
+ // Stub the request
876
+ when ( mockedGetLockupsNamesToUserMethod . callAsync ( mockedGetLockupsNamesToUserParams . user ) ) . thenResolve (
877
+ expectedGetLockupsNamesToUserResult ,
878
+ ) ;
879
+
880
+ const mockedParams = {
881
+ userAddress : expectedLockUpInvestorAddress ,
882
+ lockupName,
883
+ txData : { } ,
884
+ safetyFactor : 10 ,
885
+ } ;
886
+ const expectedResult = getMockedPolyResponse ( ) ;
887
+ // Mocked method
888
+ const mockedMethod = mock ( MockedSendMethod ) ;
889
+ // Stub the method
890
+ when ( mockedContract . addLockUpByName ) . thenReturn ( instance ( mockedMethod ) ) ;
891
+ // Stub the request
892
+ when (
893
+ mockedMethod . sendTransactionAsync (
894
+ mockedParams . userAddress ,
895
+ objectContaining ( stringToBytes32 ( mockedParams . lockupName ) ) ,
896
+ mockedParams . txData ,
897
+ mockedParams . safetyFactor ,
898
+ ) ,
899
+ ) . thenResolve ( expectedResult ) ;
900
+
901
+ // Real call
902
+ const result = await target . addLockUpByName ( mockedParams ) ;
903
+
904
+ // Result expectation
905
+ expect ( result ) . toBe ( expectedResult ) ;
906
+ // Verifications
907
+ verify ( mockedContract . addLockUpByName ) . once ( ) ;
908
+ verify (
909
+ mockedMethod . sendTransactionAsync (
910
+ mockedParams . userAddress ,
911
+ objectContaining ( stringToBytes32 ( mockedParams . lockupName ) ) ,
912
+ mockedParams . txData ,
913
+ mockedParams . safetyFactor ,
914
+ ) ,
915
+ ) . once ( ) ;
916
+ verify ( mockedSecurityTokenOwnerMethod . callAsync ( ) ) . once ( ) ;
917
+ verify ( mockedSecurityTokenContract . owner ) . once ( ) ;
918
+ verify ( mockedSecurityTokenDecimalsMethod . callAsync ( ) ) . once ( ) ;
919
+ verify ( mockedSecurityTokenContract . decimals ) . once ( ) ;
920
+ verify ( mockedContract . securityToken ) . twice ( ) ;
921
+ verify ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . twice ( ) ;
922
+ verify ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . twice ( ) ;
923
+ verify ( mockedWrapper . getAvailableAddressesAsync ( ) ) . once ( ) ;
924
+ verify ( mockedContract . getLockUp ) . once ( ) ;
925
+ verify (
926
+ mockedGetLockupMethod . callAsync ( objectContaining ( stringToBytes32 ( mockedGetLockupParams . lockupName ) ) ) ,
927
+ ) . once ( ) ;
928
+ verify ( mockedContract . getLockupsNamesToUser ) . once ( ) ;
929
+ verify ( mockedGetLockupsNamesToUserMethod . callAsync ( mockedGetLockupsNamesToUserParams . user ) ) . once ( ) ;
930
+ } ) ;
931
+ } ) ;
932
+
817
933
describe ( 'verifyTransfer' , ( ) => {
818
934
test ( 'should verify Transfer' , async ( ) => {
819
935
const statusCode = new BigNumber ( 2 ) ;
0 commit comments