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

Commit

Permalink
Merge e47dff3 into 8c8f8df
Browse files Browse the repository at this point in the history
  • Loading branch information
monitz87 committed Sep 10, 2019
2 parents 8c8f8df + e47dff3 commit 54def18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
weiToValue,
valueToWei,
packVersion,
stringToBytes32,
stringToKeccak256,
} from '../../../utils/convert';
import { MockedCallMethod, MockedSendMethod, getMockedPolyResponse } from '../../../test_utils/mocked_methods';
import { FULL_DECIMALS, FeeType } from '../../../types';
Expand Down Expand Up @@ -881,21 +881,21 @@ describe('SecurityTokenRegistryWrapper', () => {
const mockedParams = {
feeType: FeeType.TickerRegFee,
};
const bytes32 = stringToBytes32('tickerRegFee');
const keccak256 = stringToKeccak256('tickerRegFee');
// Mocked method
const mockedMethod = mock(MockedSendMethod);
// Stub the method
when(mockedContract.getFees).thenReturn(instance(mockedMethod));
// Stub the request
when(mockedMethod.callAsync(objectContaining(bytes32))).thenResolve(expectedResult);
when(mockedMethod.callAsync(objectContaining(keccak256))).thenResolve(expectedResult);

// Real call
const result = await target.getFees(mockedParams);
// Result expectation
expect(result).toEqual(expectedResult);
// Verifications
verify(mockedContract.getFees).once();
verify(mockedMethod.callAsync(objectContaining(bytes32))).once();
verify(mockedMethod.callAsync(objectContaining(keccak256))).once();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
weiToValue,
valueToWei,
packVersion,
stringToBytes32,
stringToKeccak256,
} from '../../utils/convert';
import functionsUtils from '../../utils/functions_utils';

Expand Down Expand Up @@ -1213,8 +1213,8 @@ export default class SecurityTokenRegistryWrapper extends ContractWrapper {
if (![FeeType.StLaunchFee, FeeType.TickerRegFee].includes(feeType)) {
assert.assert(false, ErrorCode.InvalidData, 'Incorrect fee type');
}
const feeTypeBytes32 = stringToBytes32(params.feeType);
return (await this.contract).getFees.callAsync(feeTypeBytes32);
const feeTypeKeccak256 = stringToKeccak256(params.feeType);
return (await this.contract).getFees.callAsync(feeTypeKeccak256);
};

/**
Expand Down
6 changes: 5 additions & 1 deletion src/utils/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export function bytes32ToString(value: string): string {
}

export function stringToBytes32(value: string): string {
return ethers.utils.formatBytes32String(value);
return ethers.utils.formatBytes32String(value);
}

export function stringToKeccak256(value: string): string {
return ethers.utils.id(value);
}

export function checksumAddress(value: string): string {
Expand Down

0 comments on commit 54def18

Please sign in to comment.