Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit df88d21

Browse files
author
Victor Wiebe
committed
fix: 🐛 _modifyTicker assertions missing for existing ticker st
1 parent a260457 commit df88d21

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/contract_wrappers/registries/__tests__/security_token_registry_wrapper.test.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,13 @@ describe('SecurityTokenRegistryWrapper', () => {
695695
txData: {},
696696
safetyFactor: 10,
697697
};
698+
const securityToken = '0x9999999999999999999999999999999999999999';
699+
// Mocked method
700+
const mockedGetSecurityTokenAddressMethod = mock(MockedCallMethod);
701+
// Stub the method
702+
when(mockedContract.getSecurityTokenAddress).thenReturn(instance(mockedGetSecurityTokenAddressMethod));
703+
// Stub the request
704+
when(mockedGetSecurityTokenAddressMethod.callAsync(mockedParams.ticker)).thenResolve(securityToken);
698705

699706
// checkOnlyOwner
700707
const expectedOwnerResult = '0x0123456789012345678901234567890123456789';
@@ -739,21 +746,32 @@ describe('SecurityTokenRegistryWrapper', () => {
739746
verify(mockedContract.owner).once();
740747
verify(mockedOwnerMethod.callAsync()).once();
741748
verify(mockedWrapper.getAvailableAddressesAsync()).once();
749+
verify(mockedContract.getSecurityTokenAddress).once();
750+
verify(mockedGetSecurityTokenAddressMethod.callAsync(mockedParams.ticker)).once();
751+
742752
});
743753
});
744754

745755
describe('ModifyExistingSecurityToken', () => {
746756
test('should call modifyExistingSecurityToken with ModifyExistingSecurityTokenParams', async () => {
757+
const securityToken= '0x5555555555555555555555555555555555555555';
747758
const mockedParams = {
748759
ticker: "TTEST",
749760
owner: "0x0023456789002345678900234567890023456789",
750-
securityToken: "0x1123456789112345678911234567891123456789",
761+
securityToken,
751762
tokenDetails: "",
752763
deployedAt: new Date(2018, 10, 10),
753764
txData: {},
754765
safetyFactor: 10,
755766
};
756767

768+
// Mocked method
769+
const mockedGetSecurityTokenAddressMethod = mock(MockedCallMethod);
770+
// Stub the method
771+
when(mockedContract.getSecurityTokenAddress).thenReturn(instance(mockedGetSecurityTokenAddressMethod));
772+
// Stub the request
773+
when(mockedGetSecurityTokenAddressMethod.callAsync(mockedParams.ticker)).thenResolve(securityToken);
774+
757775
// checkOnlyOwner
758776
const expectedOwnerResult = '0x0123456789012345678901234567890123456789';
759777
const mockedOwnerMethod = mock(MockedCallMethod);
@@ -797,6 +815,8 @@ describe('SecurityTokenRegistryWrapper', () => {
797815
verify(mockedContract.owner).once();
798816
verify(mockedOwnerMethod.callAsync()).once();
799817
verify(mockedWrapper.getAvailableAddressesAsync()).once();
818+
verify(mockedContract.getSecurityTokenAddress).once();
819+
verify(mockedGetSecurityTokenAddressMethod.callAsync(mockedParams.ticker)).once();
800820
});
801821
});
802822

@@ -2000,6 +2020,13 @@ describe('SecurityTokenRegistryWrapper', () => {
20002020
safetyFactor: 10,
20012021
};
20022022

2023+
// Mocked method
2024+
const mockedGetSecurityTokenAddressMethod = mock(MockedCallMethod);
2025+
// Stub the method
2026+
when(mockedContract.getSecurityTokenAddress).thenReturn(instance(mockedGetSecurityTokenAddressMethod));
2027+
// Stub the request
2028+
when(mockedGetSecurityTokenAddressMethod.callAsync(mockedParams.ticker)).thenResolve(securityToken);
2029+
20032030
const expectedResult = getMockedPolyResponse();
20042031
// Mocked method
20052032
const mockedMethod = mock(MockedSendMethod);
@@ -2042,6 +2069,8 @@ describe('SecurityTokenRegistryWrapper', () => {
20422069
verify(mockedContract.owner).once();
20432070
verify(mockedOwnerMethod.callAsync()).once();
20442071
verify(mockedWrapper.getAvailableAddressesAsync()).once();
2072+
verify(mockedContract.getSecurityTokenAddress).once();
2073+
verify(mockedGetSecurityTokenAddressMethod.callAsync(mockedParams.ticker)).once();
20452074
});
20462075
});
20472076

src/contract_wrappers/registries/security_token_registry_wrapper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
747747
assert.assert(params.expiryDate.getTime() > new Date(0).getTime(), 'Bad expiry date');
748748
assert.assert(params.registrationDate.getTime() > new Date(0).getTime(), 'Bad registration date');
749749
assert.isNonZeroETHAddressHex('owner', params.owner);
750+
if (params.status) {
751+
const address = await this.getSecurityTokenAddress(params.ticker);
752+
assert.isNonZeroETHAddressHex('address', address);
753+
}
750754
return (await this.contract).modifyExistingTicker.sendTransactionAsync(
751755
params.owner,
752756
params.ticker,
@@ -766,6 +770,8 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
766770
assert.assert(params.ticker.length > 0 && params.ticker.length <= 10, 'Bad ticker');
767771
assert.assert(params.deployedAt.getTime() > new Date(0).getTime(), 'Bad deployed date');
768772
assert.isNonZeroETHAddressHex('owner', params.owner);
773+
assert.isNonZeroETHAddressHex('Security token not registered for ticker',
774+
await this.getSecurityTokenAddress(params.ticker));
769775
return (await this.contract).modifyExistingSecurityToken.sendTransactionAsync(
770776
params.ticker,
771777
params.owner,
@@ -979,6 +985,8 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
979985
assert.assert(params.ticker.length <= 10, 'Ticker length can not be greater than 10');
980986
assert.isNonZeroETHAddressHex('owner', params.owner);
981987
assert.isNonZeroETHAddressHex('securityToken', params.securityToken);
988+
assert.isNonZeroETHAddressHex('Security token not registered for ticker',
989+
await this.getSecurityTokenAddress(params.ticker));
982990
return (await this.contract).modifySecurityToken.sendTransactionAsync(
983991
params.name,
984992
params.ticker,

0 commit comments

Comments
 (0)