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

Commit de698ce

Browse files
author
Victor Wiebe
committed
fix: 🐛 onlyOwner assertion missing from setLatestVersion
1 parent 251c919 commit de698ce

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,17 @@ describe('SecurityTokenRegistryWrapper', () => {
731731

732732
describe('SetLatestVersion', () => {
733733
test('should call setLatestVersion with PackageVersionParams', async () => {
734+
// Owner Address expected
735+
const expectedOwnerResult = '0x5555555555555555555555555555555555555555';
736+
// Mocked method
737+
const mockedOwnerMethod = mock(MockedCallMethod);
738+
// Stub the method
739+
when(mockedContract.owner).thenReturn(instance(mockedOwnerMethod));
740+
// Stub the request
741+
when(mockedOwnerMethod.callAsync()).thenResolve(expectedOwnerResult);
742+
// Mock web3 wrapper owner
743+
when(mockedWrapper.getAvailableAddressesAsync()).thenResolve([expectedOwnerResult]);
744+
734745
const mockedParams = {
735746
version: "3.0.0",
736747
txData: {},
@@ -771,6 +782,9 @@ describe('SecurityTokenRegistryWrapper', () => {
771782
mockedParams.safetyFactor,
772783
),
773784
).once();
785+
verify(mockedContract.owner).once();
786+
verify(mockedOwnerMethod.callAsync()).once();
787+
verify(mockedWrapper.getAvailableAddressesAsync()).once();
774788
});
775789
});
776790

src/contract_wrappers/registries/security_token_registry_wrapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
11491149
* Changing versions does not affect existing tokens.
11501150
*/
11511151
public setLatestVersion = async (params: PackageVersionParams) => {
1152+
await this.checkOnlyOwner();
11521153
assert.isValidVersion(params.version);
11531154
const splitVersion = params.version.split('.');
11541155
const major = new BigNumber(splitVersion[0]);

0 commit comments

Comments
 (0)